Player cannot walk if it runs out of stamina

This commit is contained in:
Marcin Kostrzewski 2020-04-06 10:57:44 +02:00
parent 4a33b6e761
commit 6994f39864

View File

@ -22,15 +22,17 @@ class Player(Entity):
# Move in a desired direction # Move in a desired direction
def move(self, rotation): def move(self, rotation):
self.movePoints += 1 self.movePoints += 1
self.applyWalkingFatigue() # You can only move if you have enough stamina
if rotation.value == Rotations.NORTH.value: if self.statistics.stamina > 1:
self.rect.y -= self.rect.w self.applyWalkingFatigue()
elif rotation.value == Rotations.EAST.value: if rotation.value == Rotations.NORTH.value:
self.rect.x += self.rect.w self.rect.y -= self.rect.w
elif rotation.value == Rotations.SOUTH.value: elif rotation.value == Rotations.EAST.value:
self.rect.y += self.rect.w self.rect.x += self.rect.w
elif rotation.value == Rotations.WEST.value: elif rotation.value == Rotations.SOUTH.value:
self.rect.x -= self.rect.w self.rect.y += self.rect.w
elif rotation.value == Rotations.WEST.value:
self.rect.x -= self.rect.w
def applyWalkingFatigue(self): def applyWalkingFatigue(self):
# looses hunger every 10 steps taken # looses hunger every 10 steps taken