C# Corner - Snake

By Emil


Source Code: Snake

There is a nice simple snake game on C# Corner written by someone calling themselves Emil. The article consists of the a link to the source code and two lines of text which pretty much say, "here is a snake game". The original article and original code can be found at http://www.c-sharpcorner.com/Code/2005/May/SnakeGame.asp.

The code consists of three main classes which do all of the work:

Class Description
snakeForm The form upon which everything is drawn and where the keypresses are handled.
Snake Holds an array of points which make up the snake, with all routines for manipulating the points.
Food Holds the location of the food.

The original code came with its own about form, which hs been removed. I have added a High score table and rules.

Class Description
EntryForm High Score Name Entry Form.
HighScoreForm Form to display the top ten highest scores.
HighScoreEntry Simple class to store name and associated score.
HighScoreTable Handles loading and saving of high score table.
RulesForm Form to display the rules from a rtf file.

As the code is so simple, there are possibilites to improve on the game, adding random food to shrink the snake, slow down the time (or increse it to be nasty), or give bonus points. Mmmm, I feel Snake II is coming just around the corner.


<< Yahtzee Contents Asteroids >>

© Publicjoe, 2008