Simple C++ Tetris Game Project
CPPND: Capstone Simple Tetris Game Repo
This is a Simple Tetris Game Repo for the Capstone project in the Udacity C++ Nanodegree Program.
This project structure is inherited from The empty starter Github repositry.
And Simple Tetris Game is inherited from CppND-Capstone-Tetris-Game.
My solution: Github Repo.
With adding some features as follow:
- Move all config for screen to main.cpp.
- Fix code to show window title ans close button, also display score and FPS.
- Move handle input evens to Controller class (Added Controller class).
- Move render business to Render class (Added Render class).
- Add score log when terminate the game.
Here is image captured from the game:
Dependencies for Running Locally
cmake >= 3.7
- All OSes: click here for installation instructions
make >= 4.1 (Linux, Mac), 3.81 (Windows)
- Linux: make is installed by default on most Linux distros
- Mac: install Xcode command line tools to get make
- Windows: Click here for installation instructions
SDL2 >= 2.0
- All installation instructions can be found here
Note that for Linux, an
apt
orapt-get
installation is preferred to building from source. - MacOS, Apple Silicon (Mx chips):
1
2
3
4
5
6
7git clone https://github.com/libsdl-org/SDL.git -b SDL2
cd SDL
mkdir build
cd build
../configure
make
sudo make install- All installation instructions can be found here
gcc/g++ >= 5.4
- Linux: gcc / g++ is installed by default on most Linux distros
- Mac: same deal as make - install Xcode command line tools
- Windows: recommend using MinGW
Basic Build Instructions
Clone this repo
1
git clone git@github.com:KhoiVuKha/CppND-Capstone-Simple-Tetris-Game.git
Make a build directory in the top level directory:
1
mkdir build && cd build
Compile:
1
cmake .. && make
Run it:
1
./SimpleTetrisGame
How to play
- Player should place the falling tetrominos in a way that the Well has as less as possible empty cells.
- When line in the Well has no empty cells, it is deleted.
- Player can rotate tetrominos, accelerate their fall.
- Player fails, when at least one figure exaggerates the game field on the top.
- For one deleted line player receives 100 scores.
Controll the game by some key evens:
- Left arrow - move the tetromino left.
- Right arrow - move the tetromino right.
- Down - move the tetromino down.
- Space - Rotate the tetromino.
Project structure
The Simple Tetris game code consists of five main classes: Game, Tetromino, Well, Controller, and Renderer.
- To begin, main creates a Controller, a Game, and a Renderer object. Game stores a Tetromino and Well object as part of the state.
- main calls Game::Run to start the game loop.
Here is project structure:
Simple C++ Tetris Game Project
https://khoivu.netlify.app/projects/Simple-C-Tetris-Game-Project/