91 lines
2.6 KiB
Markdown
91 lines
2.6 KiB
Markdown
# 🐍 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
|
|

|
|
|
|
---
|
|
|
|
### 🏆 Leaderboard
|
|

|
|
|
|
---
|
|
|
|
### 🎮 In-Game
|
|

|
|
|
|
---
|
|
|
|
## ⚙️ 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:
|
|
```bash
|
|
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.
|