Snake

A few years before the dawn of the iPhone, we all had Nokias with the addictive Snake game installed. The premise of snake was simple: eat all the food on the screen without hitting your tail or a wall. The more food you eat, the longer your tail became.

Paul Jensen has returned to that era for his addictive Snake canvas game, and has also provided a handy tutorial on how he created it.

Green dots never tasted better!

Comments from the author:

The canvas element is used to map the playing area of the game where the Snake moves. The Snake consists of a collection of xy coordinates on the canvas element, and the movement is simulated by drawing and removing the xy coordinates from the canvas element.

The tutorial itself is a handy guide for those who are a little unsure of where to start when it comes to using user interactions to manipulate the canvas from reading the key pressed to checking your object is still within the boundaries of the canvas.

Play the game, or check out the tutorial

Info

Type:
Games, Intermediate, Puzzle, Tutorials
Author:
Paul Jensen
Posted on:
January 1st, 2010
Posted by:
Andi Smith
Views:
10974

Rating

3.81

Your Rating:
1 Star2 Stars3 Stars4 Stars5 Stars

Works on

BETA Please let us know if you find Snake works in other browsers by leaving a comment below.

Comments

Andi Smith

The on-screen score doesn’t seem to update in Firefox, but will still give you a grand total at the end of the game.

Posted on December 31, 2009

Manuel Ignacio López Quintero

Wow! One of the best tutorial I’ve never seen! Now I understand clearly the Timer object!

Bookmarked!

Posted on November 12, 2010

Andrew

works fine in opera 11.0

Posted on February 2, 2011

Chris

Wow… was Nokia really your first introduction to Snake? I feel sooo old for making clones of this game on my old VIC-20 10 years before the first cellphone game came out.

I believe this game was made somewhere around 1981, as a pre-runner to the Atari and NES games, it was also standard on the Comodore 64 (the descendant of the VIC-20).

It’s a cool game, don’t get me wrong, but Nokia did not invent it, and the phone version was just another clone of an already popular game ;)

Posted on March 2, 2012

Chris

BTW, after much tinkering with this script, I finally made it work. I don’t know if it’s Firefox or Windows that’s the problem here, or if the javascript engine have been changed, but arrays can no longer take strings as parameters, so change all arrays to numbers (example: currentPosition['x'] should be currentPosition[0]) and it works fine.

Posted on March 2, 2012

Darrin

Hi, just to set the record straight since the question was mentioned here. The first version of snake was written on a TRS80 computer. It started off as an experiment while learning to use the graphics and key functions of the TRS80 basic around 1980.

I think one of the reasons the origin was obscured is because the original version that got sold in Europe was “taken” from the original author by some university CS students (original author was a “high”-school student in New Zealand).

Posted on August 18, 2012

Gabriel

This page is dead .. :-(

Posted on June 29, 2014

Add comment

(required)
(required)
(will not be published)
(required)