Chapter 3 Snake Game
We have learned how control 2D and 3D figures. Now, we will use ESP32 board to play the classic snake game. There are both 2D and 3D version.
Project 3.1 Snake Game
First, let’s play a 2D snake game.
Component List
ESP32-WROVER x1
|
GPIO Extension Board x1
|
Breadboard x1
|
|
Joystick x1
|
Jumper M/M x3
|
Circuit
Use Pin36 and Pin39 (A0 and A3) ports to detect the voltage value of two rotary potentiometers inside joystick.
Schematic diagram |
|
Hardware connection |
|
Sketch
Sketch Snake_Game
Use Processing to open Freenove Ultimate Starter Kit for ESP32CProcessingProcessingBox_3DBox_3D.pde , and click Run.Snake_Game.pde and click Run. If the connection succeeds, the follow will be shown:
Press the space bar on keyboard to start the game:
Shift the joystick to control the snake action. The game rules are the same as the classic snake game:
When the game fails, press space bar to restart the game:
Additionally, you can restart the game by pressing the space bar at any time.
Project 3.2 Snake Game 3D
Now, let’s experience the 3D version game.
Component list
The same as last section.
Circuit
The same as last section.
Sketch
Sketch Snake_Game_3D
Use Processing to open Freenove Ultimate Starter Kit for ESP32CProcessingProcessingSnake_Game_3DSnake_Game_3D.pde Snake_Game_3D.pde and click Run. If the connection succeeds, the follow will be shown:
Press the space bar on keyboard to start the game:
Shift the joystick to control the snake action. The game rules are the same as the classic snake game:
The rest operation is the same as the 2D version.






