Closed sunjay closed 7 years ago
Hi @sunjay, It is completely possible to write code such as the snippet above. The code below was taken from a working system, the BrainStation(https://github.com/brain-labs/brainstation).
setup
>>>>>>>?:++; we will only have two sprites at cell 7
build values for distant cells for later jump
>?<<<<<:++++++++>+*>+*>+++++++*<--*<---*<<<<<<;
?->>>>>>^>>>+<<<<^:<<; if btn DOWN add Y of human object
?->>>>>>>>^>>>-<<<<^; if btn UP subtract Y of human object
player
>>>>>>>>^?:++; make number two if cell 41 is empty
<<?:++++++;>> go to cell 38 and make it 6 if empty
>+% add 1 to cell 42 and take it mod 2 because of the sprite number
<<?:+;^ go back to cell 1
monster 1
>>>>>>>>>^?:++; go to cell 48 and make number two if cell 48 is empty
>+%++ add 1 to cell 49 and take it mod 2 and add 2 because of monster sprite
>?--:++>_%<++++++++++++; if cell 16 is equal to 0 then we reset it to 15
?: if cell 50 is equal to zero
> go to cell 51
? check if it is different from zero
<<<<<<<< go to cell 43
?<<<<<^?:+;; if cell 43 different from zero then game over
: if cell 51 equal to zero
<<<<<<<< go to cell 43
?:<<<<<^?:+;; if cell equal to zero then game over
;
;
You should also be able to find other examples here: https://github.com/brain-labs/brain/tree/master/tests
Brain also has it's own visualizer for fast tests purposes here: https://brain-labs.github.io/brain-visualizer/
Thank you
?+++++++?;; nested if
Nested ifs(without elses) are also possible
Do you support code like this?
Expanded:
Are you able to figure out which
:
to jump to?