A classic Snake game built using C++ and the SDL2 library as a final project for the second semester of the first year. This game includes features such as player history, name input, and best score tracking.
- Course: CSE-1211 (Fundamentals of Programming)
- Institution: University of Dhaka
- Developer: Mehedi Hasan
This project recreates the timeless Snake game, where players control a snake that grows longer by consuming food items while avoiding collisions with itself and screen borders. It runs offline in single-player mode, keeping a record of player history and the highest score.
- Single-player gameplay: Enjoy a classic offline game mode where you control a snake.
- Player Name Input: Input and save your name along with your score.
- Score History: Keep track of scores from previous games.
- Best Score Display: See the highest score achieved across all games.
- Offline Play: No internet connection required.
![]() |
![]() |
|---|---|
| Main Menu. | Gameplay. |
- C++ Programming Language: Handles core game logic and functionality.
- SDL2 Library: Powers graphics and input handling.
- SDL2_ttf: Renders text elements, such as scores and player names.
- SDL2_image: Manages images for game graphics.
- C++ Compiler (e.g., GCC or MSVC)
- SDL2 Library installed (along with
SDL2_ttfandSDL2_imageif used). You can download it from SDL2
-
Clone the repository or download the source code.
git clone https://github.com/hasanmehediii/CSE-1211-Project cd CSE-1211-Project -
Ensure SDL2 is properly installed.
sudo apt update sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev
-
Compile the project using your C++ compiler. For example:
g++ -o main main.cpp -lSDL2 -lSDL2_ttf -lSDL2_image
-
Run
./main
If you have any questions, feedback, or suggestions, feel free to reach out!
- Email: mehedi-2022415897@cs.du.ac.bd
- Institution: CSE, University of Dhaka


