I am making a top-down shooter and want my zombie to follow my character, and my program uses a main loop. The position of my character is x and y and he is controlled by the arrow keys. I have a zombie that as of right now randomly spawns at the left edge of the screen when shot at. How can I make the zombie follow my position from where it spawns?
This is the zombie function:
def makezombie():
global zom
zom = Rect (0,randint(0, height-40), 49, 38)
return zom
I set zombie=makezombie()
In my main loop I have the following:
for shot in shots:
if zombie.collidepoint(shot[X],shot[Y]):
zombie=makezombie()
points+=1000
impact.play()
blood.play()