Snake Game

This is a short and simple game program based on the mobile Snake Game popularized by the classic Nokia mobile phone models. The program demonstrates the use of Struct and Enum keywords in VB .Net 2010. The game uses the arrow keys on the keyboard. The snake increases its length and speed by 1 square unit (10 pixels x 10 pixels) and by 4 percent of its initial speed respectively for every additional 5 points garnered in the game. Initially, the time interval for the Timer control is 50 milliseconds and 4 percent of 50 is 2, this is the value we use to decrease further the time interval making the snake to move faster. Note: The execution speed for the rendering of the snake does not change no matter how long the snake turns out in the game process. This is because what we do is we only add a new 'head' and remove the current 'tail' by manipulating the collection object that holds the snake's squares (square selections).

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.


1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.


Submitted byAnonymous (not verified)on Mon, 11/05/2012 - 23:31

Good job. Perfect game. Thanks for sharing your code. I can't believe this can be done in VB.NET easily.

I designed it that way :-)... If you wish to have the game behave that way (activating wall collisions), you just have to modify this block of code:
  1. Select Case curDirection
  2. Case Direction.Downward
  3. y = y + 1
  4. If y > rowCount - 1 Then y = 0
  5. Case Direction.Leftward
  6. x = x - 1
  7. If x < 0 Then x = columnCount - 1
  8. Case Direction.Rightward
  9. x = x + 1
  10. If x > columnCount - 1 Then x = 0
  11. Case Direction.Upward
  12. y = y - 1
  13. If y < 0 Then y = rowCount - 1
  14. End Select
into this:
  1. Select Case curDirection
  2. Case Direction.Downward
  3. y = y + 1
  4. If y > rowCount - 1 Then
  5. ' Your wall collision message here
  6. End If
  7. Case Direction.Leftward
  8. x = x - 1
  9. If x < 0 Then
  10. ' Your wall collision message here
  11. End If
  12. Case Direction.Rightward
  13. x = x + 1
  14. If x > columnCount - 1
  15. ' Your wall collision message here
  16. End If
  17. Case Direction.Upward
  18. y = y - 1
  19. If y < 0 Then
  20. ' Your wall collision message here
  21. End If
  22. End Select
I am sorry I should have included some comments on the codes. Anyways, please feel free to post your queries here... I believe this site is very accommodating and always 'active' :-)...On my part... I am most willing to be of help...
Submitted byAnonymous (not verified)on Tue, 11/06/2012 - 16:44

Hi, Thanks for the code. I can't believe you finished the program within 3 hours. I hope I can do the same in the future. I'm still learning different languages today and I like
Submitted byOelasoron Tue, 11/06/2012 - 18:18

In reply to by Anonymous (not verified)

Trust's not that hard :-) ... maybe my typing speed contributes... hehehe. Boasting aside, I can develop a complete system within a week or so, provided it is well-documented and complete with diagrams and other significant details... OOP (Object-Oriented Programming) and COP (Component-Oriented Programming like .NETs) approaches in programming help a lot...Things become easy when done passionately...

I did not invent the term COP :).. try Google, there is a lot of info about COP over the Internet... By the way, this small program is not written that way. I chose not to implement the OOP or COP approach since it is just that 'small'... anyways, if one wanted to use the OOP or COP approach regardless how small the project is, it's his personal discretion. We can choose to be 'cheap' sometimes...
Submitted byjnandhinion Mon, 09/30/2013 - 15:23

Hi, i find it difficult to understand. So i need some comments to undersatnd it.
Submitted byLayer (not verified)on Wed, 01/29/2014 - 13:56

Can i ask something ? i'm a programmer student , i just want to know how to make a games in VB . Who can give me a code ? tnx :D
Submitted byvincit (not verified)on Wed, 02/12/2014 - 20:29

how to download this game?
Submitted byWawa (not verified)on Sun, 03/02/2014 - 09:51

Hello, i see in your code we cannot change the snake speed. However, is there a way to make a kind of "level difficulty" by change the speed or it's impossible ? Note: Sorry for my english, it is not my first language :)
Submitted byOelasoron Fri, 08/29/2014 - 22:20

In reply to by Wawa (not verified)

The snake's speed is automatically updated/incremented for every five (5) points you earn in the play. On the other hand, you can design the program to use a difficulty level using the speed, that is, using the Timer's Interval value.
Submitted byWAWA OH YAH (not verified)on Sat, 05/24/2014 - 03:03

Just as the title says, It crashes at 200% Snake speed. It says TMR.Interval cannot be less than 0.

Thanks for sharing that info... haven't tried the code in that speed. Somehow, to resolve that is to use a variable to update the Timer's Interval value instead of directly modifying it, thus avoiding values less than zero (0).
Submitted byB--A (not verified)on Fri, 08/29/2014 - 01:35

thanks for source code it is very benifitial for me

Submitted byAnonymous (not verified)on Tue, 01/02/2024 - 09:41

Great piece from a genius. Thank you

Add new comment