-
Notifications
You must be signed in to change notification settings - Fork 0
General description
This project aims to create an application that offers the single game mode.
The program consists of three essential phases:
- Start screen: It's the initial screen where players have the option to start a new game of Tetris.
- Game screen: This is where the main action takes place. Players must stack tetrominoes on a rectangular playing field. The goal is to arrange the pieces in such a way that they form horizontal lines. The game ends when no more tetrominoes can be placed on top of the board, in other words, when the available space is filled.
- End screen: This screen appears when the game is over. It gives users the option to return to the initial screen to start a new game or to end the program execution.
The playing field of Tetris is designed as a grid measuring 21 squares in height by 18 squares in width. Additionally, just to the right side of this main grid, there is a space dedicated to displaying the next tetromino that will be available to the player. This space allows players to see in advance the next piece they will receive, easing the strategic planning of their moves.
Finally, we decided to carry out the program entirely in English. This choice not only extends the scope and accessibility of the project to a more global audience, but also provides us with a valuable opportunity to improve our technical English skills, particularly in the area of programming.
Before embarking on the design and programming process, we dedicated some time to discuss and choose the platform we would use for version control and team collaboration. After considering several options, we opted for Github (project repository). This decision was based on the previous experience that some of the team members had with the platform.
Based on the diagram provided by our professor, we designed and developed our program. Throughout the whole process, the initial diagram undergone some modifications to fit our specific solution better. These changes were made based on the experiences and learnings obtained during the lessons and partial exercises.
The controls to carry out movement and rotations are very easy and intuitive:
- Z: Move tetromino one square to the left.
- C: Move tetromino one square to the right.
- L: Rotate tetromino one square to the left (clockwise).
- J: Rotate tetromino to the right (counterclockwise).
Each tetromino is declared as a set of data that specifies its characteristics and behaviors. The description of the general declaration pattern and some specific details are described below:
-
General structure of the declaration:
- Size and Shape: Each tetromino statement begins with the declaration of its size ( DB rows, columns) followed by the hexadecimal values representing the color of each square.
- Rotation Pointers: Then, two pointers are specified ( DW left, right) pointing to the corresponding tetrominoes for the left and right rotations of the tetromino.
- Position Settings for Rotation: Lastly, additional position settings for rotations are added due to the fact that the rotation is done based on the upper left corner.
-
Specific examples:
- O Block (Yellow): this tetromino has the same shape in all of its rotations. It is defined with 2x2 dimensions and a hexadecimal value of $30 for each square.
- I Block (Cyan): It has two shapes (vertical and horizontal) that are equal to each other. It's defined with dimensions of 4x1 and 1x4, using the hexadecimal value $28.
- Z Block (Red): Similar to the I block in terms of rotations, with dimensions of 2x3 and 3x2 and a combination of values $10 and 0.
- S Block (Green): Quite similar to the Z block regarding rotations and shape, with dimensions 2x3 and 3x2 and a hexadecimal value of $20 for the color.
- J Block (Dark Blue), L Block (Dark Yellow) and T Block (Purple): Each has unique rotations with their own dimensions and hexadecimal values representing their shape.
- Tetromino width calculation: To calculate the width of the pieces we subtract the second defined tetromino minus the first one. Since we have defined the pieces as non-variable structures (they have the same number of parameters), the result of this subtraction serves as the width (space occupied in memory by each piece) of all of them.
These statements are fundamental to the generation and manipulation of the tetrominoes in the game, as they define how each one appears visually and how it responds to rotation actions. The detailed structure allows each tetromino to behave uniquely, adding complexity and variety to the Tetris game.