Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- oGame Create Event
- state = "initializing";
- globalvar map;
- mapwidth = room_width/GRID_SIZE;
- mapheight = room_height/GRID_SIZE;
- // create grid of node objects
- 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);
- }
- }
- for(xx = 0; xx < mapwidth; xx += 1)
- {
- for(yy = 0; yy < mapheight; yy += 1)
- {
- node = map[xx, yy];
- // add left neighbour
- if(xx > 0)
- {
- ds_list_add(node.neighbours, map[xx - 1, yy]);
- }
- // add right neighbour
- if(xx < mapwidth - 1)
- {
- ds_list_add(node.neighbours, map[xx + 1, yy]);
- }
- // add top neighbour
- if(yy > 0)
- {
- ds_list_add(node.neighbours, map[xx, yy - 1]);
- }
- // add bottom neighbour
- if(yy < mapheight - 1)
- {
- ds_list_add(node.neighbours, map[xx, yy + 1]);
- }
- // add top left neighbour
- if(xx > 0 && yy > 0)
- {
- ds_list_add(node.neighbours, map[xx -1, yy -1]);
- }
- // add top right neighbour
- if(xx < mapwidth -1 && yy > 0)
- {
- ds_list_add(node.neighbours, map[xx +1, yy -1]);
- }
- // add bottom left neighbour
- if(xx > 0 && yy < mapheight - 1)
- {
- ds_list_add(node.neighbours, map[xx -1, yy +1]);
- }
- // add bottom right neighbour
- if(xx < mapwidth -1 && yy < mapheight -1)
- {
- ds_list_add(node.neighbours, map[xx +1, yy +1]);
- }
- }
- }
- instance_create(0, 0, obj_cursor);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement