Game maker

Enemy

In the create code : hsp=2

 

STEP

//moving left and right if we can!

if place_free(x+hsp,y){x+=hsp}

else

{hsp=-hsp}

//colliding with the player.

if instance_exists(obj_player)

{if place_meeting(x,y-1,obj_player)&&

obj_player.vspeed > 0

{instance_destroy()

with (obj_player){vspeed=-3}}

if(place_meeting(x+hsp,y,obj_player)||

place_meeting(x-hsp,y,obj_player))

{with(obj_player){instance_destroy()}}}

//gravity

if place_free(x,y+1){gravity=0.5}

else

gravity = 0

 

COLLISION WITH ThE WALL

 

if vspeed>0&&!place_free(x,y+vspeed){move_contact(270)}

vspeed=0