sweep
Member
Hi
( I know this topic must have been brought up a thousand times before.)
I am working on a top down game. I've been through the forum looking for a way to get the enemy to animate when chasing the player. I have the enemy sprites set up for 4 directional movement. I've tried tweaking the player animation code but i can't figure out how to tell the enemy its xx, yy ??
player animation code
xx = move_right - move_left;
yy = move_down - move_up;
hspd = xx*spd;
vspd = yy*spd;
if (keyboard_check(vk_right))
{
xx += hspd;
image_speed = hspd/3
sprite_index = spr_player_right;
}
if (keyboard_check(vk_up))
{
yy -= vspd;
image_speed = vspd/3
sprite_index = spr_player__up;
}
if (keyboard_check(vk_left))
{
xx -= hspd;
image_speed = hspd/3
sprite_index = spr_player_left;
}
if (keyboard_check(vk_down))
{
yy+= vspd;
image_speed = vspd/3
sprite_index = spr_player;
}
if (vspd == 0) and (hspd == 0)
{
image_speed = 0
}
( I know this topic must have been brought up a thousand times before.)
I am working on a top down game. I've been through the forum looking for a way to get the enemy to animate when chasing the player. I have the enemy sprites set up for 4 directional movement. I've tried tweaking the player animation code but i can't figure out how to tell the enemy its xx, yy ??
player animation code
xx = move_right - move_left;
yy = move_down - move_up;
hspd = xx*spd;
vspd = yy*spd;
if (keyboard_check(vk_right))
{
xx += hspd;
image_speed = hspd/3
sprite_index = spr_player_right;
}
if (keyboard_check(vk_up))
{
yy -= vspd;
image_speed = vspd/3
sprite_index = spr_player__up;
}
if (keyboard_check(vk_left))
{
xx -= hspd;
image_speed = hspd/3
sprite_index = spr_player_left;
}
if (keyboard_check(vk_down))
{
yy+= vspd;
image_speed = vspd/3
sprite_index = spr_player;
}
if (vspd == 0) and (hspd == 0)
{
image_speed = 0
}