https://github.com/xpd54/tetris_game
Tetris Game in C++
https://github.com/xpd54/tetris_game
2d-game cpp game oops-in-cpp raylib-cpp simple-game tetris-game
Last synced: 2 months ago
JSON representation
Tetris Game in C++
- Host: GitHub
- URL: https://github.com/xpd54/tetris_game
- Owner: xpd54
- License: mit
- Created: 2024-08-21T05:39:33.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-11-05T11:21:43.000Z (8 months ago)
- Last Synced: 2024-11-05T12:35:46.319Z (8 months ago)
- Topics: 2d-game, cpp, game, oops-in-cpp, raylib-cpp, simple-game, tetris-game
- Language: C++
- Homepage:
- Size: 4.99 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tetris Game with raylib
Tetris game is built on top of [raylib](https://www.raylib.com/index.html) using C++17.
## Table of Contents
- [Dependency](#Dependency)
- [Compiling & Building](#Compiling)
- [Game Control](#Game)
- [License](#license)### 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](https://cmake.org/) as buid tool. Instruction for how to install CMake and how to setup C++ is available everywhere so skipping :).
1. [CMake](https://cmake.org/)
2. [Raylib](https://www.raylib.com/index.html)### 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.
- To install on Linux follow [official guide](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux)
- TLDR :- Easiest way to do is [install dependency](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux#ubuntu) and [build from source](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux#build-raylib-using-cmake) using cmake.
4. Move inside the Repo `cd Tetris`
5. Create a folder in root folder name `mkdir build`
6. `cd build`
7. `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`
8. 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.
## Game Control
- Left Arrow key :point_right: :- To move block left.
- Right Arrow key :point_right: :- To move block right.
- Up Arrow key :point_right: :- To rotate the block.## License
[LICENSE](https://github.com/xpd54/Tetris/blob/main/LICENSE)