4. App Snake Game
In this chapter, we will play a classic game, snake.
4.1. App Snake Game
Now, let’s create and experience our own game.
4.1.1. Component List
|
Jumper Wires x12 |
Push button x4 |
Resistor 10kΩ x4 |
4.1.2. Circuit
Schematic diagram
|
Hardware connection. If you need any support,please feel free to contact us via:
|
4.1.3. Sketch
4.1.3.1. Sketch SnakeGame
Use Processing to open the file Sketch_04_1_1_SnakeGame.
$ processing ~/Freenove_Kit/Processing/Apps/App_04_1_1_Snake_Game/App_04_1_1_Snake_Game.pde
Click on “RUN” to run the code.
After the program is executed, Display Window displays as below.
Pressing the space can start the game:
You can control the movement direction of the snake through the four buttons in circuit or four arrow keys on the keyboard. The rules are the same as the classic Snake game:
When game is over, pressing the space can restart the game:
You can restart the game by pressing the space bar at any time during the game.




