2. App Tetris Game
In this chapter, we will play a game, Tetris game.
2.1. App Tetris Game
Now, let’s create and experience our own game.
2.1.1. Component List
|
Jumper Wires x12 |
Push button x4 |
Resistor 10kΩ x4 |
2.1.2. Circuit
Schematic diagram
|
Hardware connection. If you need any support,please feel free to contact us via:
|
2.1.3. Sketch
2.1.3.1. Sketch TetrisGame
Use Processing to open the file Sketch_05_1_1_TetrisGame.
$ processing ~/Freenove_Kit/Processing/Apps/App_02_1_1_Tetris/App_02_1_1_Tetris.pde
Click on “RUN” to run the code.
After the program is executed, Display Window displays as below.
The left and right button in the circuit can control the movement of the falling block to left or right. And the button below can accelerate falling of the block. The button above is used for rotating of the block. Four direction keys on keyboard can also be used to play the game.
In the process of game, pressing the space bar on the keyboard can pause the game. The right side of the Display Window shows the upcoming block, the current game speed and the current score. The more lines you eliminate once, the higher the scores you will get. If you eliminate one line once, you will get 10 points. If you eliminate 4 lines once, you will get 70 points.
When the blocks are beyond the screen, the game is over. After the game is over, press the space bar to start a new game.




