JOEZACK.COM Code Musings and Such

12Oct/080

JavaScript Game Of Life Pt 1

I thought it would be fun to implement Conway's Game Of Life. I used ColdFusion a bit in my example to ease some typing but the "engine" is all JavaScript. Beloved Prototype is also being used a bit behind the scenes.

So without further ado, here's a

// set up a game of size 30 x 30
 
g = new Game_Of_Life(30);
 
// set some random tiles, note that you
// have way more of these for a size
// 30 board.
 
g.set_tile(2,26,1);
g.set_tile(19,20,1);
 
// draw inital board
 
g.draw();
 
// run the game, 1/25s "frame-rate"
g.run(.25);

Click to see a demonstration.

And, as always: Download the code!

PS: It looks like terrible in Internet Explorer. No comment.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.