Tetris game is built on top of raylib using C++17.
As of Oct 2024 whole game is built on mac using C++17 and raylib library. You would need working setup for C++17. I am using CMake as buid tool. Instruction for how to install CMake and how to setup C++ is available everywhere so skipping :).
As it doesn't have static libaray of raylib included. Have to install raylib in system itself. (my first choice of OS was Mac. Will include static lib or dynamic build in upcoming version).
- Clone the repository.
brew install raylib
Install raylib in your Mac first.- To install on Linux follow official guide
- TLDR :- Easiest way to do is install dependency and build from source using cmake.
- Move inside the Repo
cd Tetris
- Create a folder in root folder name
mkdir build
cd build
cmake .. && make
- You set
BUILD_BENCHMARK
BUILD_TESTS
to build unit test and benchmark (uses googlebenchmark and googletest) cmake -DBUILD_TESTS=ON -DBUILD_BENCHMARK=ON .. && make
to build both test and benchmark- To run unit test
./Tetris_tests
- To run benchmark
./Tetris_benchmark
- You set
- It will create an executable name Tetris which can be run with
./Tetris
Resource of this game (Music, Fonts) are outside the build folder, and paths to load these are relative. To get music and correct font for score copy Tetris executable to root folder and run again.
cp Tetris ../
./Tetris
this should bring music.
If compile and build failed first place to look at is setup of raylib.
inside root folder tests/test_raylib_setup.cpp follow same bulding process with creating a build folder. Executable TestRayLib should show following screen.
- Left Arrow key 👉 :- To move block left.
- Right Arrow key 👉 :- To move block right.
- Up Arrow key 👉 :- To rotate the block.