Hey, so my attempt at making a top down shooter is both amazing and a catastrophically failure. Right now with my limited knowledge I am trying to add a zombie following the player, which works properly but not really, and the zombie to aim at the player.
This is my attempt at a function that allows a sprite to follow another one.
function zombieMovement()
zx# = GetSpriteX(zombie)
zy# = GetSpriteY(zombie)
px# = GetSpriteX (player)
py# = GetSpriteY (player)
if px# < zx#
zx# = zx# - 1
endif
if px# > zx#
zx# = zx# + 1
endif
if py# < zy#
zy# = zy# - 1
endif
if py# > zy#
zy# = zy# + 1
endif
SetSpritePosition(zombie,zx#,zy#)
print(zx#)
print(zy#)
endfunction
The zombie follows the player, but only vertically and horizontally, and diagonally
It follows the player, but since it follows it in those directions only it is very easy to run away from and not challenging at all. Any tips on how to improve this?
As for getting the zombie to aim at the player, in between the
if px# > zx#
zx# = zx# + 1
endif
I have added setspriteangle(zombie,?), with the ? corresponding to the direction it is heading, so 90 heading right, 135 heading diagonally but that is not going to work with new code.
Thanks guys, You're the best help I can get in agk