A fully functional Snake game built with C# and Windows Presentation Foundation (WPF). The game features smooth movement, grid-based gameplay, and real-time player input handling through arrow keys.
- 🎮 Classic Snake gameplay
- 🎯 Collect food and grow the snake
- 💥 Collision detection with walls or self
- ⌨️ Arrow key controls
- 🧱 Grid-based rendering with XAML canvas
- 🧩 Clean modular architecture with enums and logic separation
- Language: C#
- Framework: .NET WPF
- UI: XAML
- IDE: Visual Studio 2022
git clone https://github.com/SphiweNdou/wpf-snake-game.git
cd wpf-snake-game- Open the
SSSnake.slnfile. - Set the
SSSnakeproject as the startup project. - Press
F5to run the application.
This application does not require a database. All game state is managed in memory during runtime for performance and simplicity.
- Built using WPF and XAML
- Grid rendered inside a dynamic canvas in
MainWindow.xaml - Visual updates triggered through game logic in
MainWindow.xaml.cs - Snake segments and food are drawn in real time as the snake moves
- ← / → / ↑ / ↓ – Move the snake
- Game ends if the snake hits the wall or itself
Snake.cs– Main logic for snake movement and growthDirection.cs– Enum for movement directionGridCell.cs– Class representing a cell in the playfieldMainWindow.xaml– UI layout with canvas and visual componentsMainWindow.xaml.cs– Event handling and game loop
Sphiwe Ndou
Desktop App Developer | .NET Enthusiast
GitHub: @SphiweNdou
LinkedIn: linkedin.com/in/yourprofile