Skip to content

ky-cx/SnakeGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐍 Snake Game - C# Console Application

Made with C# .NET License: MIT Platform

Classic Snake game built with C# for the terminal, demonstrating OOP principles, game loops, and collision detection algorithms.

✨ Features

  • 🎮 Classic snake gameplay with smooth controls
  • 🎯 Score tracking system
  • ⚡ Progressive difficulty (speed increases)
  • ⏸️ Pause functionality
  • 🎨 Clean ASCII art interface
  • 📊 Real-time stats display

🛠️ Technologies

  • Language: C# 10.0
  • Framework: .NET 10.0
  • Platform: Cross-platform (Windows, macOS, Linux)

🚀 Getting Started

Prerequisites

  • .NET 10.0 SDK or later

Installation & Running

# Clone the repository
git clone https://github.com/ky-cx/snake-game-csharp.git

# Navigate to project directory
cd snake-game-csharp

# Run the game
dotnet run

🎮 How to Play

Controls

  • W / ↑ - Move Up
  • S / ↓ - Move Down
  • A / ← - Move Left
  • D / → - Move Right
  • P - Pause/Resume
  • Q - Quit

Rules

  1. Control the snake to eat food (★)
  2. Each food increases score by 10 points
  3. Snake grows with each food eaten
  4. Speed increases every 50 points
  5. Avoid hitting walls or yourself!

🎯 Technical Highlights

Object-Oriented Design

  • Encapsulation of game state and logic
  • Type-safe direction handling with enums
  • Clean separation of concerns

Key Algorithms

  • Collision Detection: O(n) self-collision, O(1) boundary checks
  • Game Loop: Event-driven with fixed time steps
  • Snake Movement: Deque-like operations using List

Code Quality

  • Comprehensive XML documentation
  • SOLID principles applied
  • Clean, maintainable code structure

📊 Project Stats

  • Lines of Code: ~400
  • Development Time: ~6 hours
  • Complexity: Medium (junior-mid level)

💼 Why This Project?

This project demonstrates several key software engineering concepts:

  • OOP Principles: Encapsulation, abstraction, separation of concerns
  • Algorithm Skills: Collision detection, state management
  • Game Development: Game loop, real-time input handling
  • Code Quality: Documentation, naming conventions, clean code

Perfect for technical interviews to discuss:

  • Design patterns and architecture
  • Performance optimization strategies
  • Testing approaches
  • Potential enhancements

🔮 Future Enhancements

  • High score persistence
  • Multiple difficulty levels
  • Sound effects
  • Multiplayer mode
  • Power-ups and obstacles

👨‍💻 Author

Conghui Xu

📄 License

This project is open source and available under the MIT License.


Built with 💚 by Conghui Xu

About

Classic Snake game built with C# for cross-platform console. Demonstrates OOP principles, game loops, collision detection, and clean code architecture. Perfect portfolio project for technical interviews.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages