Elevator Rabbit | Explanations |
There are 15 bricks. There is 1 rabbit. The rabbit is controlled by the keyboard. |
Object declaration, instantiation, and initial placement. Declaration of controlled object. |
The bricks move up and down. | Unconditional statement for describing how the bricks move. Since it moves up and down, it automatically reverses direction when hitting a border. |
When right arrow is pressed, the rabbit moves right. When left arrow is pressed, the rabbit moves left. When the spacebar is pressed, the rabbit jumps. |
Conditional statements for describing how the rabbit is controlled. |
Map: -- --k----------k -- -----------k -- ----k----------k -- -------k -- -------------k --k -- -----k---------k --- --k----------k -- -----------k -- ----k----------k |
Click the image to try it |
Elevator Rabbit with Carrots | Explanations |
There are 15 bricks. There are 8 carrots near the top. There is 1 rabbit. The fox is controlled by the keyboard. |
Object declaration, instantiation, and initial placement. Declaration of controlled object. |
The bricks move up and down. | Unconditional statement for describing how the bricks move. Since it moves up and down, it automatically reverses direction when hitting a border. |
When right arrow is pressed, the rabbit moves right. When left arrow is pressed, the rabbit moves left. When the spacebar is pressed, the rabbit jumps. |
Conditional statements for describing how the rabbit is controlled. |
When the rabbit meets a carrot, the rabbit eats the carrot. When all the carrots are gone, you win. |
Conditional statement for describing collision and gameover events. |
Map: -- --k----------k -- -----------k -- ----k----------k -- -------k -- -------------k --k -- -----k---------k --- --k----------k -- -----------k -- ----k----------k |
Click the image to try it |
Can you add a few more obstacle objects to make the game more challenging?