This is a simple snake game implemented in C++ using the SDL3 library. The game allows players to control a snake that grows longer as it eats food, with the objective of avoiding collisions with itself and the walls. The game features basic graphics, providing a nostalgic experience reminiscent of classic arcade games.
- Simple and intuitive controls.
- Snake grows longer as it eats food.
- Randomly generated food.
- Game over condition when the snake collides with itself or the walls.
- Score tracking.
- Basic graphics using SDL3.
- C++ compiler (C++23 or later)
- SDL3 library
- CMake (for building the project)
- Git (for cloning the repository)
-
Clone the repository:
git clone https://github.com/giansimone/snake-game-cpp.git cd snake-game-cpp -
Install SDL3:
- On Ubuntu:
sudo apt install libsdl3-dev
- On macOS, you can use Homebrew:
brew install sdl3
- On Windows, follow the instructions on the SDL3 website to download and set up SDL3.
- On Ubuntu:
-
Build the project using CMake:
mkdir build cd build cmake .. make -
Run the game:
./bin/snake
- Arrow keys to move the snake (Up, Down, Left, Right) or WASD keys.
- Press
Escto exit the game. - Press
Rto restart the game after a game over or to reset the game. - Press
Pto pause and resume the game.
- The snake starts with a length of 1 and grows by 1 unit each time it eats food.
- The game ends when the snake collides with itself or the walls.
Contributions are welcome! If you have suggestions for improvements or new features, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
