Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. oGame Create Event
  2.  
  3. state = "initializing";
  4.  
  5. globalvar map;
  6.  
  7. mapwidth = room_width/GRID_SIZE;
  8. mapheight = room_height/GRID_SIZE;
  9.  
  10. // create grid of node objects
  11. for(xx = 0; xx < mapwidth; xx += 1)
  12. {
  13. for(yy = 0; yy < mapheight; yy += 1)
  14. {
  15.  
  16. map[xx, yy] = instance_create(xx * GRID_SIZE, yy * GRID_SIZE, obj_node);
  17. }
  18. }
  19.  
  20. for(xx = 0; xx < mapwidth; xx += 1)
  21. {
  22. for(yy = 0; yy < mapheight; yy += 1)
  23. {
  24. node = map[xx, yy];
  25.  
  26. // add left neighbour
  27. if(xx > 0)
  28. {
  29. ds_list_add(node.neighbours, map[xx - 1, yy]);
  30. }
  31.  
  32. // add right neighbour
  33. if(xx < mapwidth - 1)
  34. {
  35. ds_list_add(node.neighbours, map[xx + 1, yy]);
  36. }
  37.  
  38. // add top neighbour
  39. if(yy > 0)
  40. {
  41. ds_list_add(node.neighbours, map[xx, yy - 1]);
  42. }
  43.  
  44. // add bottom neighbour
  45. if(yy < mapheight - 1)
  46. {
  47. ds_list_add(node.neighbours, map[xx, yy + 1]);
  48. }
  49.  
  50. // add top left neighbour
  51. if(xx > 0 && yy > 0)
  52. {
  53. ds_list_add(node.neighbours, map[xx -1, yy -1]);
  54. }
  55.  
  56. // add top right neighbour
  57. if(xx < mapwidth -1 && yy > 0)
  58. {
  59. ds_list_add(node.neighbours, map[xx +1, yy -1]);
  60. }
  61.  
  62. // add bottom left neighbour
  63. if(xx > 0 && yy < mapheight - 1)
  64. {
  65. ds_list_add(node.neighbours, map[xx -1, yy +1]);
  66. }
  67.  
  68. // add bottom right neighbour
  69. if(xx < mapwidth -1 && yy < mapheight -1)
  70. {
  71. ds_list_add(node.neighbours, map[xx +1, yy +1]);
  72. }
  73. }
  74. }
  75.  
  76. instance_create(0, 0, obj_cursor);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement