Archive for November, 2012

Representing 2d and 3d data in 1 dimension.

Friday, November 23rd, 2012

When programming applications that operate on some spacial dimension we often work with maps. Specifically, if someone is writing an adventure game they may use a 2d array to store their world data. The programmer would then access elements on the map like so

var map = new Map2DWithDataAlreadyInIt();
var x = 3;
var y = 5;

console.log(map[x][y].someDataValue);

In C that kind of array access is syntactic sugar for

int ndx = map.width*y + x;

MapElement* el = map[ndx];

which shows us that storing two dimensional data in a one dimensional data structure is as simple as specializing the element access mechanism.

Similarly we can store three dimensional data in a one dimensional data structure using this formula for element access

int ndx = map.width*map.height*z + map.width*y + x;

MapElement* el = map[ndx];

You can see that the element access equation for two dimensions is contained inside the equation for three dimensions, which means our equation is recursive, fun huh? So you can guess that next we could use this pattern to store four dimensional data in one dimension or eleven dimensional data in one dimension – just by using a single array and a special access equation.

So – tell me what the access equation would look like for four dimensions…

and…

give me a generalized equation of element access for n-dimensional data.

Github Game Jam 2012

Thursday, November 8th, 2012

I’ve started on my entry for github’s first game jam! My game is called “The Moonining” and this is the pre-mortem.

Moonening

The astronaut approaches.

It’s a turn based, top-down, sci-fi-horror-comedy adventure. Whew. I’ve got three weeks to write the code, draw sprites and get it all bundled up (playable). I’ll be posting details on the tech involved and progress reports as I go along. My roomy Alex Whitehurst is helping with the sprites. He’s already made some awesome character faces for the astronaut and some nice spaceship map tiles. My good friend James Barry will be doing the music and sound effects and has so far finished the title screen music. This is going to be a fun project.

Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo

Thursday, November 8th, 2012


And just to bring it back to programming, or math, or data structures, or something other than buffalo:

A tree of buffalo

Buffalo, dawg.

Praise be to DOS

Wednesday, November 7th, 2012

clicky clicky DOS

 


Follow me on GitHub
Follow me on Google+
Follow me on Twitter