This is a classic Snake game implemented as a web application using ASP.NET Core Razor Pages with JavaScript. The game features a responsive design, dynamic difficulty, and intuitive controls.
- 🐍 Classic Snake gameplay
- 🎮 Start, Pause, and Restart functionality
- 📈 Dynamic difficulty (speed increases with score)
- 🎨 Responsive and modern UI
- 🖥️ Cross-platform web compatibility
- Backend: ASP.NET Core 8.0 Razor Pages
- Frontend: HTML5 Canvas
- Languages: C#, JavaScript
- Styling: CSS
- .NET 8.0 SDK
- Web browser (Chrome, Firefox, Safari, Edge)
- Clone the repository:
git clone https://github.com/yourusername/snake-game.git
cd snake-game
- Restore dependencies:
dotnet restore
- Run the application:
dotnet run
- Open your browser and navigate to
https://localhost:5001
- Arrow Keys: Change snake direction
- Start Button: Begin the game
- Pause Button: Pause/Resume gameplay
- Restart Button: Start a new game after game over
- Snake moves continuously in the last selected direction
- Eat food to grow longer and increase score
- Avoid hitting walls or the snake's own body
- Game speed increases every 5 points
snake-game/
│
├── Controllers/
├── Pages/
│ └── Index.cshtml
│ └── Index.cshtml.cs
│
├── wwwroot/
│ ├── css/
│ │ └── snake.css
│ └── js/
│ └── snake.js
│
└── README.md
You can easily modify:
- Canvas size in
wwwroot/js/snake.js
- Game speed progression
- Styling in
wwwroot/css/snake.css
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Email: [email protected]
Project Link: https://github.com/ronishpaudel/snake-game