develop
🐍 Snake Game (C++ Console Edition)
A colorful and modern Snake Game built entirely in C++ for the terminal.
This version includes a menu system, persistent leaderboard, scoring with time tracking, smooth controls, and a retro ASCII-art UI that makes the classic snake experience both fun and polished.
🎮 Features
- 🏠 Main Menu: Start a new game, view the leaderboard, or exit.
- 👤 Player Names: Each player enters their name before starting, and their performance is tracked.
- 🎯 Scoring System:
- +10 points for each fruit collected
- Timer shows how long you survived
- Score combined with time for leaderboard ranking
- 🏆 Leaderboard: Sorted by score (higher is better), with time used as a tiebreaker.
- 🐍 Snake Mechanics: Grow longer each time you eat fruit, but avoid running into your own tail!
- 🔄 Wrap-Around Walls: When hitting borders, snake reappears on the opposite side.
- ⏱ Time Tracking: Total game duration is displayed alongside your score.
- 🎨 Colorful Console Graphics: Snake, fruits, borders, and leaderboard are all highlighted with ANSI colors.
- 💾 Persistent Save: Player data is stored in
leaderboard.txtso you can keep competing across sessions. - ⚡ Fast and Simple UI: Runs directly in terminal — no extra dependencies.
📷 Screenshots
🏠 Main Menu
🏆 Leaderboard
🎮 In-Game
⚙️ Setup & Run
✅ Requirements
- A C++ compiler (e.g., g++, MSVC)
- Windows OS (project uses
conio.handwindows.h) - Console with UTF-8 and ANSI color support
📦 Build & Run
On Windows:
g++ -o snake snake.cpp -std=c++11
snake.exe
On Linux/macOS:
⚠️ This version relies on Windows-specific libraries. For Linux/macOS, small adjustments are required (replace
conio.handwindows.hwith platform-specific functions).
🕹️ Controls
Wor Up Arrow → Move UpSor Down Arrow → Move DownAor Left Arrow → Move LeftDor Right Arrow → Move RightESC→ End the game immediately
📁 Project Files
snake.cpp→ Main source codeleaderboard.txt→ Stores player leaderboard data
👤 Creator
Name: [Meraj Derafshi]
Contact/Portfolio: [https://github.com/MerajDerafshi]
📜 License
This project is open-source. Feel free to use, modify, or expand it for learning or fun. Attribution is appreciated.
Description
🐍A colorful and modern Snake Game built entirely in C++ for the terminal.🐍
59 KiB
Languages
C++
100%


