Coder Profile - Show off your skills, get a coder profile.
 
 
 
The Author
VBAssassin
Scott Thompson
Send A Message
Screenshot
View Full Size
snake.png ( 0.01Mb )
Rating
8.00
out of 10
( 2 Ratings )
Please login to rate source codes.

Click here to register a free account with us.
General Details
JavaScript
Posted 4.8 Years Ago
1,916 Views
Received 2 Ratings
More Codes By This Author
Pick A Random Array Eleme...
Bitwise Settings (Class)...
Compare Ratings, and Retu...
Settings Class
Dynamic Parameters (Using...
Articles By This Author
[PHP] - Lets kill the com...
How to use Memcache on Wi...
PHP Sessions = Member Dat...
Speed Up Delivery of your...
AJAX - When to use it?

Snake Game


Description
A basic snake game that ONLY works on FireFox. I was inspired to create this after seeing a Mario javascript based game the other day. Took about 4 hours to develop this game and all i wanted to achieve was a working version of the game to prove to myself i could write the algorithms needed. I am NOT going to make this cross compatible with other browsers since that was not the aim of me making this game.

The game starts off with a 500 x 700 grid and you have to eat the apples to grow. Even though there are some strange settings such as "setting_fixed_tail" which when set to true, will keep the snake constantly growing! lol.

Eventually i will convert this algorithm across to software instead of using javascript making it in to a proper game - with two players, high scores, etc.

To run this... save the source code in a file called: snake.html & open it with firefox. The game will start straight away.

Alternatively... open the zip file attachment, extract it to your desktop... and open the file in firefox.

Enjoy :-)
Technical
If you want to change the settings of the game at any time. Open up the source code in a text editor and scroll down to where you see a comment saying "GAME SETTINGS" - read the comments on the right of each setting to understand what it does.

var setting_resolution = 10; //higher number = bigger snake & bigger blocks
var setting_grid_dimentions_x = 700; //width
var setting_grid_dimentions_y = 500; //height
var setting_allow_to_hit_self = false; //do you want to allow your snake to go over its own body?
var setting_show_grid = false; //mainly used for debugging & development reasons - set to false
var setting_snake_speed = 35; //speed of the snake (milli seconds eg 1 second = 1000 miliseconds)
var setting_fixed_tail = false; //ability to keep the snake constantly growing! lol
var setting_snake_starting_size = 2; //ability to keep the snake constantly growing! lol
Source Code
Download Download Source Code
snake.zip ( 0.00Mb )
NEVER open a .exe, .bat, .cmd, or other executable file since that is where viruses are likely to live. Please virus scan all files you download.
Comments
Please login to post comments.
 
VBAssassin     Posted 4.7 Years Ago
 
 
About 4 hours :-)
 
otoom     Posted 4.8 Years Ago
 
 
Looks tight man.
How long did it take you to code this up?

Btw, fancy uploading it somewhere?
I can't be arsed =D. Go lots to do at the moment.
 
VBAssassin     Posted 4.8 Years Ago
 
 
Lol, just change the settings to make the snake slower:

var setting_snake_speed = 35;

change it to

var setting_snake_speed = 100;

and it will be almost 3 times slower ;-)

Kind regards,
Scott
 
Relish     Posted 4.8 Years Ago
 
 
Hard game ;-)
Page 1 of 1
More "JavaScript" Source Codes By This Author
Recently Posted "JavaScript" Source Codes
Recently Rated "JavaScript" Source Codes
 
 
Latest News About Coder Profile
Coder Profile Poll
Why do you get bored with programming?

Not enough time to do something productive
I run out of ideas
Too hard to show people my creations
Everything i do has too many errors, and it's too hard
I don't get bored!!!


please login to cast your vote
and see the results of this poll
Latest Coder Profile Changes
Coder Profile was last updated
3.49 Years Ago
Official Blog :: Make A Donation :: Credits :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents :: Wallpapers
Version 1.46.00
Copyright © 2007 - 2012, Scott Thompson, All Rights Reserved