Added pickup to move method
This commit is contained in:
parent
b3d38403ad
commit
649b61a84e
@ -105,9 +105,10 @@ class Player(Entity):
|
|||||||
if not self.alive:
|
if not self.alive:
|
||||||
self.image, null = self.getTexture("gravestone.png", self.rect.h)
|
self.image, null = self.getTexture("gravestone.png", self.rect.h)
|
||||||
|
|
||||||
def move(self, movement):
|
def move(self, movement, interactableObject=None):
|
||||||
"""
|
"""
|
||||||
Overriden function. Adds fatigue to the movement.
|
Overriden function. Adds fatigue to the movement.
|
||||||
|
:param interactableObject: Object to interact with
|
||||||
:type movement: entities.Enums.Movement
|
:type movement: entities.Enums.Movement
|
||||||
:param movement: specify what movement should be done (See Movement enum)
|
:param movement: specify what movement should be done (See Movement enum)
|
||||||
:return: Returns true, if the movement has succeeded
|
:return: Returns true, if the movement has succeeded
|
||||||
@ -115,14 +116,19 @@ class Player(Entity):
|
|||||||
# Can move if timeout has elapsed
|
# Can move if timeout has elapsed
|
||||||
if self.movementTimer > self.moveTimeout:
|
if self.movementTimer > self.moveTimeout:
|
||||||
self.movementTimer = 0
|
self.movementTimer = 0
|
||||||
# Rotation
|
# Movement
|
||||||
if movement.value != Movement.FORWARD.value:
|
if movement.value == Movement.FORWARD.value:
|
||||||
self.updateRotation(movement)
|
|
||||||
# Else move
|
|
||||||
else:
|
|
||||||
self.moveForward()
|
self.moveForward()
|
||||||
|
|
||||||
self.applyWalkingFatigue()
|
self.applyWalkingFatigue()
|
||||||
|
# Interaction
|
||||||
|
elif movement.value == Movement.PICKUP.value and interactableObject is not None:
|
||||||
|
try:
|
||||||
|
interactableObject.on_interaction(self)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
# Rotation
|
||||||
|
else:
|
||||||
|
self.updateRotation(movement)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user