depth = -y; global.healths += 1; if global.healths >= 1001 { global.healths = 1000; } // Keyboard commands if keyboard_check_direct(ord("Z")) { global.maindir = direction if shot == 0 { if global.ammos > 0 { iii = instance_create(x,y,obj_bullet_player); with (iii) { speed = 25; direction = global.maindir; } global.ammos -= 1 sound_play(snd_bullet_1); sound_play(snd_bullet_2); } else { if global.clips >= 1 and reloading <= 0 and global.ammos != 14 { global.clips -= 1; global.ammos = 14; reloading = 50; } if global.clips == 0 and global.ammos == 0 { sound_play(snd_reload_1); } } } shot = 1; } else { if reloading == 49 sound_play(snd_reload_1) if reloading == 46 sound_play(snd_reload_2) if reloading == 6 sound_play(snd_reload_1) if reloading == 3 sound_play(snd_reload_2) if reloading <= 0 shot = 0; else reloading -= 1; } if keyboard_check_direct(ord("X")) { if global.clips >= 1 and reloading <= 0 and global.ammos != 14 { reloading = 50; global.ammos = 14; global.clips -= 1; } } if keyboard_check_direct(vk_up) { if keyboard_check_direct(vk_right) { if direction != 45 { if direction == 225 direction = 45; if direction > 225 or direction < 45 direction += 2.5; if direction < 225 and direction > 45 direction -= 2.5; } } else { if keyboard_check_direct(vk_left) { if direction != 135 { if direction == 315 direction = 135; if direction > 315 or direction < 135 direction += 2.5; if direction < 315 and direction > 135 direction -= 2.5; } } else { if direction != 90 { if direction == 270 direction = 90; if direction > 270 or direction < 90 direction += 2.5; if direction < 270 and direction > 90 direction -= 2.5; } } } speed = 2 } if keyboard_check_direct(vk_down) { if keyboard_check_direct(vk_right) { if direction != 315 { if direction == 135 direction = 315; if direction > 135 and direction < 315 direction += 2.5; if direction < 135 or direction > 315 direction -= 2.5; } } else { if keyboard_check_direct(vk_left) { if direction != 225 { if direction == 45 direction = 225; if direction > 45 and direction < 225 direction += 2.5; if direction < 45 or direction > 225 direction -= 2.5; } } else { if direction != 270 { if direction == 90 direction = 270; if direction > 90 and direction < 270 direction += 2.5; if direction < 90 or direction > 270 direction -= 2.5; } } } speed = 2; } if keyboard_check_direct(vk_right) { if keyboard_check_direct(vk_up) { if direction != 45 { if direction == 225 direction = 45; if direction > 225 or direction < 45 direction += 2.5; if direction < 225 and direction > 45 direction -= 2.5; } } else { if keyboard_check_direct(vk_down) { if direction != 315 { if direction == 135 direction = 315; if direction > 135 and direction < 315 direction += 2.5; if direction < 135 or direction > 315 direction -= 2.5; } } else { if direction != 0 { if direction == 180 direction = 0; if direction > 180 direction += 2.5; if direction < 180 and direction != 0 direction -= 2.5; } } } speed = 2; } if keyboard_check_direct(vk_left) { if keyboard_check_direct(vk_up) { if direction != 135 { if direction == 315 direction = 135; if direction > 315 or direction < 135 direction += 2.5; if direction < 315 and direction > 135 direction -= 2.5; } } else { if keyboard_check_direct(vk_down) { if direction != 225 { if direction == 45 direction = 225; if direction > 45 and direction < 225 direction += 2.5; if direction < 45 or direction > 225 direction -= 2.5; } } else { if direction != 180 { if direction == 0 direction = 180; if direction < 180 direction += 2.5; if direction > 180 direction -= 2.5; } } } speed = 2; } if (place_meeting(x+hspeed,y,obj_walls)) { repeat(abs(hspeed)) { if (!place_meeting(x+sign(hspeed),y,obj_walls)) { x += sign(hspeed); } else { break; } } hspeed = 0; } if (place_meeting(x,y+vspeed,obj_walls)) { repeat(abs(vspeed)) { if (!place_meeting(x,y+sign(vspeed),obj_walls)) { y += sign(vspeed); } else { break; } } vspeed = 0; } if y > 1744 { win = 1; instance_destroy(); } if global.healths < 1 { win = -1; instance_destroy(); } if speed > 0 and !sound_isplaying(snd_walk) sound_play(snd_walk); image_index = round(direction / 360 * 16);