Advertisement
Guest User

obj_astar_create

a guest
Feb 12th, 2018
965
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. randomize(); //get random node positions for the sake of this example
  2.  
  3. //add 100 nodes to the room
  4. for (var i=0; i<100;++i)
  5. {
  6. instance_create(random(room_width),random(room_height),obj_node);
  7. }
  8.  
  9. //get a random start and end node from all the nodes
  10. startNode = instance_id[irandom(instance_number(obj_node)-1)];
  11. endNode = instance_id[irandom(instance_number(obj_node)-1)];
  12.  
  13. //start node is green, end node is red
  14. with (startNode)
  15. {
  16. image_blend = c_green;
  17. }
  18.  
  19. with (endNode)
  20. {
  21. image_blend = c_red;
  22. }
  23.  
  24. //we will store all nodes from the path here
  25. //including the start and end nodes
  26. pathNodes = ds_list_create();
  27. maxRange = 128; //how far apart can the nodes be before they are too far away from each other
  28. found = false; //just a boolean if there is a current path found
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement