Skip to content

A classic Snake game implemented using Windows Presentation Foundation (WPF) in C#. This project demonstrates real-time game logic, keyboard interaction, and 2D rendering via the XAML canvas system.

Notifications You must be signed in to change notification settings

SphiweNdou/SSSnake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Snake Game โ€“ WPF Desktop App (C#)

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.

๐Ÿ Features

  • ๐ŸŽฎ 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

๐Ÿงฐ Tech Stack

  • Language: C#
  • Framework: .NET WPF
  • UI: XAML
  • IDE: Visual Studio 2022

๐Ÿ› ๏ธ Setup Instructions

1. Clone the Repository

git clone https://github.com/SphiweNdou/wpf-snake-game.git
cd wpf-snake-game

2. Open the Solution in Visual Studio

  • Open the SSSnake.sln file.
  • Set the SSSnake project as the startup project.
  • Press F5 to run the application.

๐Ÿงฉ Database Setup

This application does not require a database. All game state is managed in memory during runtime for performance and simplicity.

๐Ÿ–ผ๏ธ User Interface

  • 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

๐ŸŽฎ Controls

  • โ† / โ†’ / โ†‘ / โ†“ โ€“ Move the snake
  • Game ends if the snake hits the wall or itself

๐Ÿ“ Project Structure

  • Snake.cs โ€“ Main logic for snake movement and growth
  • Direction.cs โ€“ Enum for movement direction
  • GridCell.cs โ€“ Class representing a cell in the playfield
  • MainWindow.xaml โ€“ UI layout with canvas and visual components
  • MainWindow.xaml.cs โ€“ Event handling and game loop

๐Ÿ‘จโ€๐Ÿ’ป Author

Sphiwe Ndou
Desktop App Developer | .NET Enthusiast
GitHub: @SphiweNdou
LinkedIn: linkedin.com/in/yourprofile

About

A classic Snake game implemented using Windows Presentation Foundation (WPF) in C#. This project demonstrates real-time game logic, keyboard interaction, and 2D rendering via the XAML canvas system.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages