Tuesday, October 5th, 2010

Wolfenstein 3D… in 1K of JavaScript

Category: Games, JavaScript

<>p>The JS1K conference wrapped up recently. One of the winners that jumped out at me recently was an implementation of Wolfenstein 3D…. in 1K of JavaScript:

The author mentions some of the features:

WOLF1K features a 32×32 map ( a 1024 cells grid ) with textured walls colored by orientation ( North, South, East, West ), fog, 3 transparent bitmap graphics in 8×8, 15 rainbow characters steering smoothly across the map, collision detection, probably the most crazy optimization tricks I ever wrote.

In order to get this into 1K some crazy things had to be done:

WOLF1K works exactly like the original Wolfenstein 3D and Wolf 5k. It is using the raycasting technique. The world is built from a uniform grid of walls and corridors. In order to draw the world, a single ray is traced for every column of screen pixels and a vertical slice of wall texture is selected, scaled and colored according to where in the world the ray hits a wall and how far it travels before doing so.

The sprites and graphics are stored in a small space using a clever trick:

The world of WOLF1K is a regular grid of 32×32 cells. Obviously storing these 1024 cells in one byte or one bit each is not feasible. It would use the 1024 bytes or 128 bytes if stored as bits. It actually is the result of a binary operation applied to the ASCII codes of the source code of WOLF1K plus a mural on each edge of the world.

[via Paul Kinlan]

Posted by Brad Neuberg at 9:31 am
3 Comments

+++--
3.9 rating from 15 votes

3 Comments »

Comments feed TrackBack URI

The nice thing about this is that Wolf 5K (http://www.the5k.org/) was a standout in the original HTML 5K competition.

Comment by Michael Mahemoff — October 5, 2010

nice game lol, but where is the shoot botton ? (next step, collision gestion) ;o)

Comment by MMOSTR — October 26, 2010

it’s amazing, i cant believe that this game was made with just 1k javascript! However, how to shoot?

Comment by jiksaw213 — April 25, 2012

Leave a comment

You must be logged in to post a comment.