Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (keyboard_check_pressed(vk_space))
- {
- //reset the previous path - make blue nodes white
- //and recolour start and end nodes
- for (var i=0;i<ds_list_size(pathNodes);++i)
- {
- var inst = ds_list_find_value(pathNodes,i);
- with (inst)
- {
- image_blend = c_white;
- }
- }
- with (startNode)
- {
- image_blend = c_green;
- }
- with (endNode)
- {
- image_blend = c_red;
- }
- ds_list_clear(pathNodes); //clear the list of nodes
- //find the path between start and end nodes
- //and make the variable true if a path is found, else false
- found = scr_findPath(startNode,endNode,pathNodes,maxRange);
- //colour all the nodes between the start and end nodes with a blue colour
- for (var i=1;i<ds_list_size(pathNodes)-1;++i)
- {
- var inst = ds_list_find_value(pathNodes,i);
- with (inst)
- {
- image_blend = c_blue;
- }
- }
- }
- //left click = make selected node a start node
- if (mouse_check_button_pressed(mb_left))
- {
- var inst = instance_nearest(mouse_x,mouse_y,obj_node);
- with (inst)
- {
- if (distance_to_point(mouse_x,mouse_y) <= radius)
- {
- with (obj_astar.startNode)
- {
- image_blend = c_white;
- }
- obj_astar.startNode = inst;
- image_blend = c_green;
- }
- }
- }
- //left click = make selected node an end node
- if (mouse_check_button_pressed(mb_right))
- {
- var inst = instance_nearest(mouse_x,mouse_y,obj_node);
- with (inst)
- {
- if (distance_to_point(mouse_x,mouse_y) <= radius)
- {
- with (obj_astar.endNode)
- {
- image_blend = c_white;
- }
- obj_astar.endNode = inst;
- image_blend = c_red;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement