How to write Snake game in C#?
In this page, we are sharing the source code of a "simple snake game" developed on C# programming language as a windows form application. Here are the most relevant keywords about this game: Graphics, Timer, Double Buffering, First Game, Game Loop.
You can download the source code of the snake game from here. Please download the project, and build it with Visual Studio to run the application.
Note that, the application is written in C# programming language, using old style Windows Form Applications as UI components. Try to use WPF (windows presentation foundation) for better development and maintainability experiences.
How to improve the game?
1. Level: Update timer1.Interval to be 20 smaller when the size of the snake reaches multiplicatives of 10.
2. Walls: Add 3-5 blue points that represent walls. When snake hit them, it is gameover.
3. Score: Eating a food should have an award. Actually, reaching the food faster should be rewarded. When a food appears, you can start countnig from 20 to 1 in each step and add the value to the score.
4. Bonus food: Sometimes you may create other colors of foods that have bonus snake size and points.
5. Scores: Save the best scores and create a Top 10 list.