A downloadable game

This is the first project that I built while I was learning C++. The game uses a custom state manager I created to handle transitions between menu game states and the gameplay itself. This is achieved by using a queue to Pop (remove the last state) and Push (add the current state) states into the queue. I also implemented an asset-loading script to read assets from a folder and initialise them at runtime. These assets include the images of the Tetriminos, fonts, and audio.

The gameplay is programmed using an array to represent each position in the grid. Then the tetriminos which are made up of Matrxi4x4's fall down the screen and check for a valid point to land.

The grid is drawn onto the screen and checks to see if any row is fully occupied during the game's update loop. The Tetriminos are represented in a 3D array: m_shapeData[7][4][16].  The first part of the array represents how many pieces there are (7).  The second part of the array determines which rotation the piece will be in. There are only 4 possible rotations for each piece, as they rotate by 90 degrees each time. The third part of the array is a Matrix4x4 representing which cell the piece should be drawn on. This is what the Matrix for the S shape looks like:

0, 0, 0, 0,

0, 0, 0, 0,

0, 0, 5, 5,

0, 5, 5, 0

I used a Matrix4x4 because the largest piece (i piece) is four tiles tall or wide at any given rotation. 

This Matrix falls down the screen and compares the position of its tiles to the position of the cells on the board, as well as the cell below it. If the cell below the occupied matrix position is occupied or at the bottom of the well, the Matrix will update the board cells at its current position to be occupied, and a new tetrimino will spawn at the top of the screen, starting the process again. This continues until the well becomes full and no more pieces can be played.

Download

Download
BrendanCopot_Tetris.zip 2 MB

Leave a comment

Log in with itch.io to leave a comment.