From 6994f398648e55215307c8d0012138a0b4deac27 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Mon, 6 Apr 2020 10:57:44 +0200 Subject: [PATCH] Player cannot walk if it runs out of stamina --- src/entities/Player.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/entities/Player.py b/src/entities/Player.py index c9ebaf4..266e474 100644 --- a/src/entities/Player.py +++ b/src/entities/Player.py @@ -22,15 +22,17 @@ class Player(Entity): # Move in a desired direction def move(self, rotation): self.movePoints += 1 - self.applyWalkingFatigue() - if rotation.value == Rotations.NORTH.value: - self.rect.y -= self.rect.w - elif rotation.value == Rotations.EAST.value: - self.rect.x += self.rect.w - elif rotation.value == Rotations.SOUTH.value: - self.rect.y += self.rect.w - elif rotation.value == Rotations.WEST.value: - self.rect.x -= self.rect.w + # You can only move if you have enough stamina + if self.statistics.stamina > 1: + self.applyWalkingFatigue() + if rotation.value == Rotations.NORTH.value: + self.rect.y -= self.rect.w + elif rotation.value == Rotations.EAST.value: + self.rect.x += self.rect.w + elif rotation.value == Rotations.SOUTH.value: + self.rect.y += self.rect.w + elif rotation.value == Rotations.WEST.value: + self.rect.x -= self.rect.w def applyWalkingFatigue(self): # looses hunger every 10 steps taken