Heya, this is my first post, but i hope someone can help me with my problem Here’s a chunk of my code:
//This function uses loops to generate the grid from the array below.
function drawIt(theMap)
{
var pos = 0;
var diameter = 60;
for (var y=0; y< diameter; y++)
{
for (var x=0; x<diameter; x++)
{
pos = x + (y * diameter)
if (theMap[y][x] == 0)
{
_root.attachMovie("myTile2", "tile_" + pos, pos)
_root["tile_" + pos]._x = x * diameter;
_root["tile_" + pos]._y = y * diameter;
}
else if (theMap[y][x] == 1)
{
_root.attachMovie("myTile", "tile_" + pos, pos)
_root["tile_" + pos]._x = x * diameter;
_root["tile_" + pos]._y = y * diameter;
}
}
}
}
//This is the the grid structure, 0's mean you can walk on it. 1's mean u can't.
function generateMap()
{
var genMap ="1,1,1,0,1,1,1,1,1,1|1,0,0,0,0,1,0,0,0,1|1,0,0,0,1,0,0,0,1,1|1,0,0,1,1,1,0,1,1,1|1,0,0,0,1,0,0,0,1,1|1,0,0,0,0,0,0,0,0,1|1,1,1,1,0,1,1,1,1,1|1,0,0,0,0,0,0,0,0,1|1,0,0,0,0,0,0,0,0,1|1,1,1,1,1,1,1,1,0,1";
genMap = genMap.split('|');
for (var i = 0; i< genMap.length; i++) {
map* = genMap*.split(',');
}
Basically, it generates a grid from two movie clips which are just different coloured squares. It reads in generateMap function to decide whether it will be a red square or a white square. 0 = white 1 = red. (the reds are going to prevent a sprite from travelling on them)
Anyway, at the moment the starting point for generating this grid is at 0,0 of the movie clip. I want it to generate at say 150,0 so i can add a console on the left which can control a sprite around this grid.
Any ideas?
I’ll gladly post more code or information if i’ve explained myself badly hides lol
Cheers!