//Room creation code { instance_create(mouse_x,mouse_y,obj_mouse) global.money = 0 global.SPD = 0 } //Script scr_findpath { target = argument0 if instance_exists(target) t = mp_grid_path(my_grid,path,x,y,target.x,target.y,1) if t && path_get_number(path) > 2 for (n = 1;n < path_get_number(path);n += 1) { x1 = path_get_point_x(path,n - 1) y1 = path_get_point_y(path,n - 1) x2 = path_get_point_x(path,n) y2 = path_get_point_y(path,n) x3 = path_get_point_x(path,n + 1) y3 = path_get_point_y(path,n + 1) if (x2 - x1) * (y3 - y2) = (x3 - x2) * (y2 - y1) { path_delete_point(path,n) n -= 1 } } node = 1 } //obj_blueant //Create event { selected = 0 mx = x my = y direction = random(360) my_col = make_color_rgb(255,157,0) } //Step Event { image_angle = direction motion_set(point_direction(x,y,mx,my),point_distance(x,y,mx,my) / 5) if speed > 8 + global.SPD speed = 8 + global.SPD } //Collision with obj_blueant Event { x = xprevious y = yprevious motion_set(direction,0) mx = x my = y } //Left Mouse Event { if position_meeting(mouse_x,mouse_y,self) selected = 1 else selected = 0 } //Right Mouse Event { if selected = 1 { mx = mouse_x my = mouse_y instance_create(mx,my,obj_movetarget) } } //Draw Event { draw_set_blend_mode(bm_normal) draw_sprite_ext(sprite_index,0,x,y,image_xscale,image_yscale,image_angle,c_white,1) draw_sprite_ext(sprite_index,1,x,y,image_xscale,image_yscale,image_angle,my_col,1) if selected = 1 { draw_set_color(c_white) draw_circle(x,y,34,1) } } //obj_finderant //Create Event { direction = random(360) image_xscale = .8 image_yscale = .8 my_col = c_blue Gcell = 34 my_grid = mp_grid_create(0,0,(room_width / Gcell) + 1,(room_height / Gcell) + 1,Gcell,Gcell) mp_grid_add_instances(my_grid,obj_wall,1) path = path_add() np = instance_nearest(instance_nearest(x,y,obj_buildstation).x,instance_nearest(x,y,obj_buildstation).y,obj_food) scr_findpath(np) food = 0 } //Step Event { image_angle = direction if collision_line(x,y,path_get_point_x(path,node),path_get_point_y(path,node),obj_wall,0,1) scr_findpath(np) if path_get_number(path) > node + 1 && !collision_line(x,y,path_get_point_x(path,node + 1),path_get_point_y(path,node + 1),obj_wall,0,1) node += 1 mp_potential_step(path_get_point_x(path,node),path_get_point_y(path,node),8 + global.SPD,0) if point_distance(x,y,path_get_point_x(path,path_get_number(path) - 1),path_get_point_y(path,path_get_number(path) - 1)) < 16 scr_findpath(np) if collision_circle(x,y,23,obj_buildstation,1,1) { if food = 1 && instance_exists(obj_food) { np = instance_nearest(instance_nearest(x,y,obj_buildstation).x,instance_nearest(x,y,obj_buildstation).y,obj_food) food = 0 scr_findpath(np) global.money += 100 } } } //Collision with obj_food Event { if food = 0 && instance_exists(obj_buildstation) { np = instance_nearest(x,y,obj_buildstation) food = 1 other.image_xscale -= .1 other.image_yscale -= .1 scr_findpath(np) } } //Draw Event { draw_set_blend_mode(bm_normal) draw_sprite_ext(sprite_index,0,x,y,image_xscale,image_yscale,image_angle,c_white,1) draw_sprite_ext(sprite_index,1,x,y,image_xscale,image_yscale,image_angle,my_col,1) if keyboard_check(vk_space) { mp_grid_draw(my_grid) draw_set_color(c_blue) draw_path(path,0,0,1) draw_sprite_ext(sprite_index,0,x,y,image_xscale,image_yscale,image_angle,c_white,1) draw_sprite_ext(sprite_index,1,x,y,image_xscale,image_yscale,image_angle,my_col,1) } } //obj_buildstation //Create Event { buiant = -1 USPD = -1 posiant = 90 working = 0 image_single = image_number - 1 selected = 0 } //Step Event { if USPD != -1 USPD += 1 if USPD = 800 { USPD = -1 global.SPD += 2 working = 0 } if buiant != -1 buiant += 10 if buiant = 1200 { buiant = -1 alarm[0] = 1 working = 0 } } //Alarm 0 Event { repeat(8) { if place_empty(x + lengthdir_x(100,posiant),y + lengthdir_y(100,posiant)) { instance_create(x + lengthdir_x(100,posiant),y + lengthdir_y(100,posiant),obj_blueant) posiant = 90 exit } else posiant += 45 } } //Left Mouse Event { if position_meeting(mouse_x,mouse_y,self) { selected = 1 if working = 0 { if global.SPD < 6 && obj_buildstation.USPD = -1 instance_create(x - 48,y + 55,obj_upgspd) instance_create(x,y + 55,obj_Bant) instance_create(x + 48,y + 55,obj_Bstation) } } else { if selected = 1 { with(obj_upgspd) instance_destroy() with(obj_Bant) instance_destroy() with(obj_Bstation) instance_destroy() selected = 0 } } } //Draw Event { draw_sprite(sprite_index,image_index,x,y) if buiant != -1 { draw_set_color(c_white) draw_set_font(Arial_12B) draw_set_halign(fa_center) draw_text(x,y + 40,'Building ant :' + string(floor(buiant / 12)) + string('%:')) } if USPD != -1 { draw_set_color(c_white) draw_set_font(Arial_12B) draw_set_halign(fa_center) draw_text(x,y + 40,'Upgrading speed :' + string(floor(USPD / 8)) + string('%:')) } } //obj_buildstationUC //Create Event { UC = 0 image_single = 0 } //Step Event { UC += 10 image_single = floor((UC / 40) / 8) if UC = 2000 { instance_destroy() instance_create(x,y,obj_buildstation) } } //Draw Event { draw_set_font(Arial_12B) draw_set_color(c_white) draw_set_halign(fa_center) draw_text(x,y + 40,'Constructing :' + string(round(UC / 20)) + string('%:')) draw_sprite_ext(sprite_index,image_index,x,y,1,1,0,c_white,1) } //obj_upgspd //Left Mouse Event { with(all) { if selected = 1 && object_index = obj_buildstation { USPD = 0 working = 1 } } } //obj_Bant //Left Mouse Event { with(all) { if object_index = obj_buildstation { if selected = 1 { buiant = 0 working = 1 } } } } //Draw Event { draw_sprite(sprite_index,image_index,x,y) if position_meeting(mouse_x,mouse_y,self) { draw_set_color(c_white) draw_set_halign(fa_center) draw_set_font(Arial_12B) draw_text(x,y + 24,'Build Finder Ant') if global.money < 300 draw_set_color(c_red) draw_text(x,y + 40,'$300') } } //obj_buildstation //Left Mouse Event { instance_create(mouse_x,mouse_y,obj_buildready) } //obj_mouse //Step Event { x = mouse_x y = mouse_y } //Draw Event { draw_sprite(sprite_index,image_index,x,y) draw_set_blend_mode(bm_add) draw_sprite(spr_mouseglow,1,x,y) draw_set_blend_mode(bm_normal) draw_set_color(c_black) draw_set_font(Arial_12B) draw_set_halign(fa_left) draw_text(view_xview[0] + 5,view_yview[0] + 5,'Money: ' + string(global.money)) } //obj_movetarget //Create Event { image_xscale = 0.7 image_yscale = 0.7 phase = 1 } //Step Event { if phase = 1 { image_xscale += 0.05 image_yscale += 0.05 } if image_xscale = 1 phase = 2 if phase = 2 { image_xscale -= 0.08 image_yscale -= 0.08 image_alpha -= 0.08 image_angle += 15 } if image_alpha <= 0 instance_destroy() } //obj_blockbuild //Create Event { solid = 1 } //obj_buildready //Create Event { image_single = 1 } //Step Event { if mouse_x > 40 && mouse_x < room_width - 40 x = mouse_x if mouse_y > 40 && mouse_y < room_height - 40 y = mouse_y move_snap(34,34) if collision_rectangle(x - 50,y - 50,x + 50,y + 50,obj_blockbuild,1,0) image_single = 1 else image_single = 0 } //Left Mouse Event { if image_single = 0 { instance_create(x,y,obj_buildstationUC) instance_destroy() } } //Right Mouse Event { instance_destroy() } //Draw Event { draw_sprite(sprite_index,image_index,x,y) draw_set_color(c_white) draw_rectangle(x - 50,y - 50,x + 50,y + 50,1) } //obj_wall //Create Event { solid = 1 } //obj_food //Step Event { if image_xscale <= .5 instance_destroy() }