-
-
Save danprince/659a54f31c0c3e4e7a86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//spr_EnemyDead is a speparate sprite that contains the image of the enemy rotated slightly. | |
//Trying to get enemy once hit, to switch to spr_EnemyDead and then fall off screen, at the moment, as soon | |
//as player bounces off head he switches back to alive sprite. | |
//Enemy Movement | |
hsp = dir * movespeed; | |
vsp += grav; | |
sprite_index = spr_enemy | |
//Horizontal Collision | |
if (place_meeting(x + hsp, y, obj_wall || obj_GravBlock)) { | |
while(!place_meeting(x + sign(hsp), y, obj_wall)) and sprite_index = spr_enemy { | |
x += sign(hsp); | |
} | |
hsp = 0 | |
dir *= -1 | |
} | |
//Movement through lava | |
if (place_meeting(x, y, obj_lava)) { | |
vsp = (vsp / 1.1); | |
} | |
if (place_meeting(x, y, obj_lava)) { | |
hsp = (hsp / 3); | |
} | |
x += hsp; | |
//Vertical Collision | |
if (place_meeting(x, y + vsp, obj_wall || obj_GravBlock)) and sprite_index = spr_enemy { | |
while(!place_meeting(x, y + sign(vsp), obj_wall)) { | |
y += sign(vsp); | |
} | |
vsp = 0 | |
} | |
y += vsp; | |
//Enemy Collision | |
if (place_meeting(x, y, obj_player)) { | |
if (obj_player.y < y-16) { | |
with (obj_player) { | |
vsp = -jumpspeed; | |
sprite_index = spr_EnemyDead; | |
} | |
} else { | |
game_restart(); | |
} | |
} else { | |
sprite_index = spr_enemy; | |
} | |
if sprite_index = spr_EnemyDead { | |
hsp = 0; | |
vsp = 2; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment