Skip to content

xpd54/Tetris_Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tetris Game with raylib

Tetris game is built on top of raylib using C++17.
Tetris

Table of Contents

Dependency

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 :).

  1. CMake
  2. Raylib

Compiling & Building

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).

  1. Clone the repository.
  2. brew install raylib Install raylib in your Mac first.
  3. Move inside the Repo cd Tetris
  4. Create a folder in root folder name mkdir build
  5. cd build
  6. 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
  7. 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.
Testing raylib setup

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. TestRayLib

Game Control

  • Left Arrow key 👉 :- To move block left.
  • Right Arrow key 👉 :- To move block right.
  • Up Arrow key 👉 :- To rotate the block.

License

LICENSE