fix mob movement

This commit is contained in:
Xevion
2020-04-21 18:44:54 -05:00
parent 9b133749af
commit 3d5b0f636c
3 changed files with 20 additions and 11 deletions

View File

@@ -44,22 +44,25 @@ class Mob(arcade.Sprite):
"""
A on_update function, the Mob should decide it's next actions here.
"""
pos, next = self.nearestPosition(), path[0]
curpos, nextpos = self.nearestPosition(), path[1]
print(curpos, nextpos)
if next[0] > pos[0]:
self.change_x = Config.PLAYER_MOVEMENT_SPEED
elif next[0] < pos[0]:
self.change_x = -Config.PLAYER_MOVEMENT_SPEED
if nextpos[0] > curpos[0]:
self.change_x = Config.PLAYER_MOVEMENT_SPEED - 3
elif nextpos[0] < curpos[0]:
self.change_x = -Config.PLAYER_MOVEMENT_SPEED + 3
else:
self.change_x = 0
if next[1] > pos[1]:
self.change_y = Config.PLAYER_MOVEMENT_SPEED
elif next[1] < pos[1]:
self.change_y = Config.PLAYER_MOVEMENT_SPEED
if nextpos[1] > curpos[1]:
self.change_y = Config.PLAYER_MOVEMENT_SPEED - 3
elif nextpos[1] < curpos[1]:
self.change_y = -Config.PLAYER_MOVEMENT_SPEED + 3
else:
self.change_y = 0
print(self.change_x, self.change_y)
def get_path(self, end: Tuple[int, int] = None) -> List[Tuple[int, int]]:
"""
Returns the path to get to the Mob's target in absolute integer positions.