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 SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
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.
Comments
B--A (not verified)
Fri, 08/29/2014 - 01:35
Permalink
Thanks source code
thanks for source code it is very benifitial for me
Oelasor
Fri, 08/29/2014 - 21:44
Permalink
You are most welcome... :)
You are most welcome... :)
Lao Tzu - “Give a man a fish and you feed him for a day. Teach a man how to fish and you feed him for a lifetime.”
Oelasor
WAWA OH YAH (not verified)
Sat, 05/24/2014 - 03:03
Permalink
It crashes at 200% Speed?
Just as the title says, It crashes at 200% Snake speed. It says TMR.Interval cannot be less than 0.
Oelasor
Fri, 08/29/2014 - 22:12
Permalink
Thanks for sharing that info.
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).
Lao Tzu - “Give a man a fish and you feed him for a day. Teach a man how to fish and you feed him for a lifetime.”
Oelasor
Anonymous (not verified)
Mon, 03/10/2014 - 02:00
Permalink
You made all program on 22
You made all program on 22 lines?
Wawa (not verified)
Sun, 03/02/2014 - 09:51
Permalink
Snake speed
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 :)
Oelasor
Fri, 08/29/2014 - 22:20
Permalink
The snake's speed is
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.
Lao Tzu - “Give a man a fish and you feed him for a day. Teach a man how to fish and you feed him for a lifetime.”
Oelasor
vincit (not verified)
Wed, 02/12/2014 - 20:29
Permalink
project
how to download this game?
bon (not verified)
Sat, 02/01/2014 - 23:59
Permalink
how to download ? :(
how to download ? :(
Layer (not verified)
Wed, 01/29/2014 - 13:56
Permalink
To get Information
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
jnandhini
Mon, 09/30/2013 - 15:23
Permalink
need of comments
Hi,
i find it difficult to understand. So i need some comments to undersatnd it.
Anonymous (not verified)
Sun, 06/23/2013 - 12:10
Permalink
i think it is a nice game
i think it is a nice game
Anonymous (not verified)
Tue, 11/06/2012 - 16:44
Permalink
Hi,
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 vb.net.
Oelasor
Tue, 11/06/2012 - 18:18
Permalink
Trust me...it's not that hard
Trust me...it'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...
Lao Tzu - “Give a man a fish and you feed him for a day. Teach a man how to fish and you feed him for a lifetime.”
Oelasor
Pickles. (not verified)
Wed, 01/13/2016 - 23:36
Permalink
Hey, its our first first time
Hey, its our first first time jerk.
Oelasor
Wed, 11/07/2012 - 02:51
Permalink
I did not invent the term COP
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...
Lao Tzu - “Give a man a fish and you feed him for a day. Teach a man how to fish and you feed him for a lifetime.”
Oelasor
Anonymous (not verified)
Tue, 11/06/2012 - 20:29
Permalink
I really wanted to learn OOP
I really wanted to learn OOP thats why I am studying it every day.And by the way what is COP? I just heard it from you...
Anonymous (not verified)
Mon, 11/05/2012 - 23:31
Permalink
Good job. Perfect game.
Good job. Perfect game. Thanks for sharing your code.
I can't believe this can be done in VB.NET easily.
Oelasor
Tue, 11/06/2012 - 06:41
Permalink
You're welcome. It took me 3
You're welcome. It took me 3 hours to write the codes. I am sure it is still buggy... :-)
Lao Tzu - “Give a man a fish and you feed him for a day. Teach a man how to fish and you feed him for a lifetime.”
Oelasor
Anonymous (not verified)
Tue, 11/06/2012 - 08:58
Permalink
After few minutes of playing,
After few minutes of playing, I think the only problem is the snake does not failed when hitting the wall. Is this normal?
Oelasor
Tue, 11/06/2012 - 10:08
Permalink
I designed it that way :-)...
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:
into this:
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...
Lao Tzu - “Give a man a fish and you feed him for a day. Teach a man how to fish and you feed him for a lifetime.”
Oelasor
Add new comment