PDA

View Full Version : game grid


johosher
02-22-2008, 05:45 PM
I need to create a grid that i can put movieclips into and so that i can keep track of the other cells in the grid around me. how do i do this? please help!

andrewProgrammer
03-31-2008, 08:55 PM
You need to use a set of arrays. Each array needs to have the same number of objects as you do collums, and the number of arrays needs to be how many rows you have. Hope that help somewhat! I a making a game kind of like that, but i am realizing that it is going to take so much FREAKIN' CODE.

rrh
04-01-2008, 03:21 PM
And you can keep your arrays in an array, and then access them like so:
theGrid[xindex][yindex]Though to keep the indexes in the natural order (x,y) you need to do it backwards to what andrew said. Each sub-array would be one column, not one row.

Durnus
04-01-2008, 06:49 PM
ar grid:Array = new Array();

var GRID_WIDTH = 50;
var GRID_HEIGHT = 50;

for(var i = 0; i < GRID_WIDTH; i++)
{
grid.push(new Array(GRID_HEIGHT));
}

...if you didn't already figure this out. :)