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 90 Days Ago
658 Views
Received 2 Ratings
More Codes By This Author
Make maxlength='' work on...
Dynamic Transparent GIF P...
To Do List (With Effects)
Breadcrumb Function
Remove Transparency
Articles By This Author
Speed Up Delivery of your...
AJAX - When to use it?
Null Byte Poison - How it...
Versioning Your Applicati...
When to use OOP in PHP

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 87 Days Ago
 
 
About 4 hours :-)
 
otoom     Posted 89 Days 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 90 Days 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 90 Days Ago
 
 
Hard game ;-)
Page 1 of 1
More "JavaScript" Source Codes By This Author
Recently Posted "JavaScript" Source Codes
Recently Rated "JavaScript" Source Codes
 
 
Part of the MyPingle Network
Development Blog :: Make A Donation :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents
Version 1.44.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved