A classic Snake game built with C++ and Raylib, developed as a hands-on project to learn the C++ language from scratch.
This project was initially built by following the tutorial below, then expanded with my own modifications and improvements:
You control a snake across a 2D grid using the arrow keys. An apple appears randomly on the grid — eat it to grow your snake and increase your score. The snake wraps around the screen edges, appearing on the opposite side when crossing a border. The game ends if the snake's head collides with any part of its own body.
| Key | Action |
|---|---|
| ↑ Arrow | Move Up |
| ↓ Arrow | Move Down |
| ← Arrow | Move Left |
| → Arrow | Move Right |
- Raylib v5.5 installed in your environment
- Any C++ compiler (MSVC, GCC, Clang)
- IDE that supports C++
- Clone the repository:
git clone https://github.com/GuilhermeAQN/SnakeRaylibCPP
- Make sure Raylib is linked to your project
- Build and run
- Language: C++ 17
- IDE: Visual Studio Community 2022
- Graphics Library: Raylib v5.5
- Key C++ concepts applied:
- Classes and Object-Oriented Programming
- STL containers (
std::deque) - Functions and scope
- Variables and type casting
- Conditionals and loops
- Third-party library integration
RetroSnake/
├── graphics/
│ └── food.png # Food sprite
├── sounds/
│ ├── eat.mp3 # Sound played when food is eaten
│ └── wall.mp3 # Sound played on game over
├── main.cpp # Full game source code
└── README.md
- Individual snake sprites — separate head, body, tail and corner sprites, similar to the original Nokia Snake game
- In-body food indicator — a visual marker showing where the eaten food is traveling through the snake's body, just like the original Nokia game
- Main menu screen — title screen with play, options and quit buttons
- Stage system — multiple levels with increasing speed and new obstacle layouts
- Gameplay timer — track and display how long the player survives each run
- Improved scoring system — combo multipliers for eating food in quick succession, bonus points for surviving longer
- High score board — save and display the top scores locally
- Obstacles — static walls inside the grid that increase in number each stage
- Power-ups — temporary effects like slow motion, score multiplier or invincibility
- Ghost mode — a limited-time ability to pass through your own body
- Web build — compile to WebAssembly with Emscripten so anyone can play in the browser without installing anything
This project was built as my first C++ project, with the goal of learning the language through practical game development. Raylib was chosen for its simplicity, allowing me to focus on C++ fundamentals rather than low-level graphics boilerplate.
This project is open source and available under the MIT License.
Developed by Guilherme Nogueira
