🐍 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.txt so you can keep competing across sessions.
  • Fast and Simple UI: Runs directly in terminal — no extra dependencies.

📷 Screenshots

🏠 Main Menu

Menu


🏆 Leaderboard

Leaderboard


🎮 In-Game

Gameplay


⚙️ Setup & Run

Requirements

  • A C++ compiler (e.g., g++, MSVC)
  • Windows OS (project uses conio.h and windows.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.h and windows.h with platform-specific functions).


🕹️ Controls

  • W or Up Arrow → Move Up
  • S or Down Arrow → Move Down
  • A or Left Arrow → Move Left
  • D or Right Arrow → Move Right
  • ESC → End the game immediately

📁 Project Files

  • snake.cpp → Main source code
  • leaderboard.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.

S
Description
🐍A colorful and modern Snake Game built entirely in C++ for the terminal.🐍
Readme
59 KiB
Languages
C++ 100%