top of page


About the project

Engine: Unreal Engine

Language: C++

During my "C++ Games Programming" module of my degree, one of my assignments was to create Tetris in Unreal Engine using only C++ (no blueprint scripting). This was a fun challenge and a good introduction to Unreal Engine.

Tetris: Bio

Completing a row

The spaces in the game are held using a 2 dimensional array, when your Tetrimino (Tetris shapes) has been placed the game checks over each row to see if all of the indexes in that row are equal to 1 (1 being occupied, 0 being empty).
In the event of a completed row, the game adds all of the Minos (singular cubes of a Tetrimino) in the row to an array, this array is looped over in the Tick function to create the destroy animation. The index in the array is used as the time offset to create the delay before spinning.

The code snippet below is called in the Tick function, passing in the index and delta time as parameters. 

Tetris: Text
Tetris: Image
Tetris: Image

Extra Time

In the original Tetris, when your Tetrimino can't move down any further, but has room to move left or right, you have a tiny amount of time where you can shift your Tetrimino across. I added this into my Tetris. 

During the "extra time" the game runs a function checking if all of the Minos can move down and if they are not at the bottom of the grid. If both of these conditions are true for all of the Minos then the extra time is cancelled and the Tetrimino will continue to move down. 

The code snippet below shows the extra time check.

Tetris: Text
Tetris: Image
Tetris: Image

Auto movement

During testing, I found occasionally I wanted to hold the movement input as tapping it to go from one side to the other became tedious and frustrating.

To implement this, I used an int value which ranged from -1 (left), to 1 (right), if the player holds down a movement key, a timer is decremented, if the value is below 0 then the Tetrimino attempts to move in the chosen direction.

The code snippet below shows the Tick function of the movement class.

Tetris: Text
Tetris: Image

Source code

To view all of the above scripts, along with many unmentioned ones, that I created during the development of 'Tetris', click the button below to go a GitHub repository with all of the .cpp and .h files.

Tetris: Text
bottom of page