I

#### Isaiah Reyes

##### Guest

This is the relative code

globalvar map;

mapWidth = room_width/GRID_SIZE;

mapHeight = room_height/GRID_SIZE;

// create nodes!

for(xx = 0; xx < mapWidth; xx += 1){

for(yy = 0; yy < mapHeight; yy +=1){

map[xx, yy] = instance_create (xx * GRID_SIZE, yy * GRID_SIZE, obj_node);

}

}

//populate neighbor lists!!

for(xx = 0; xx < mapWidth; xx += 1){

for(yy = 0; yy < mapHeight; yy =+ 1){

node = map[xx, yy];

//add left neighbor

if(xx > 0){

ds_list_add(node.neighbors, map[xx - 1, yy]);

}

//add right neighbor

if(xx < mapWidth - 1){

ds_list_add(node.neighbors, map[xx + 1, yy]);

}

//add top neighbor

if(yy > 0){

ds_list_add(node.neighbors, map[xx, yy - 1]);

}

//add bottom neighbor

if(yy < mapHeight - 1){

ds_list_add(node.neighbors, map[xx, yy + 1]);

}

//top left neighbor

if(xx > 0 && yy > 0){

ds_list_add(node.neighbors, map[xx - 1, yy - 1]);

}

//top right neighbor

if(xx < mapWidth - 1 && yy > 0){

ds_list_add(node.neighbors, map[xx + 1, yy - 1]);

}

//bottom left neighbor

if(xx > 0 && yy < mapHeight - 1){

ds_list_add(node.neighbors, map[xx - 1, yy + 1]);

}

//bottom right neighbor

if(xx < mapWidth - 1 && yy < mapHeight - 1){

ds_list_add(node.neighbors, map[xx + 1, yy + 1]);

}

}

}

instance_create(x, y, obj_cursor);