Python basic project actual combat - Tetris

1. Tetris game design analysis:
Tetris is a computer, mobile phone, and handheld game console product that has been popular all over the world from the beginning to the present. It is a simple game with simple rules but not lacking in fun. Classic mini-games, easy to learn, widely applicable, well-known. The basic rule of the Tetris game is that 7 different regular graphics composed of 4 small squares fall from the top of the screen one after another, press the direction keys to adjust the position and direction of the plates, and spell out a complete line or several lines at the bottom. These complete horizontal bars will disappear to make room for the newly fallen tiles, the player scores, the game level increases, and the blocks that have not been eliminated continue to pile up, and once the pile reaches the top, the game is over.
1. Interface settings
Border: Set 15x25 spaces, and the box falls inside
Box: The small squares that make up the box are the basic units that make up the box Box
: Each box is composed of 4 boxes;
Box shape: Set T, S , Z ,J, L, I , O these 7 types


2. The core setting of Tetris:
use random numbers to obtain a random box form, and then use a list to store all the styles after it is flipped.
Then realize its left, right and downward movement;
when the block reaches the bottom of the frame or touches other blocks, it lands, and another block is randomly generated from the top and continues to move down, and so on;
Judgment Whether the squares at the bottom of the interface fill up a row, delete them and let other squares move down to the bottom at one time.
Deleting a line will increase the score accordingly. After the score reaches a certain value, the level will increase, the falling speed of the cube will become faster, and the difficulty of the game will increase.
3. Event processing:
flip: up arrow key calls the flip method of Tetris core
move down: space arrow key calls the down method of Tetris core

Guess you like

Origin blog.csdn.net/a316495442/article/details/127985630