Refactor Interactable.py and Pickupable.py
This commit is contained in:
parent
c6ab7cc2f4
commit
6d1dc4ffb7
@ -3,12 +3,12 @@ from src.entities.Entity import Entity
|
|||||||
|
|
||||||
class Interactable(Entity):
|
class Interactable(Entity):
|
||||||
def __init__(self, texture, size, pos, Statistics):
|
def __init__(self, texture, size, pos, Statistics):
|
||||||
super().__init__(texture, size, pos, Statistics)
|
super().__init__(texture, size, pos)
|
||||||
self.Statistics = Statistics
|
self.Statistics = Statistics
|
||||||
|
|
||||||
def on_interaction(self, Player):
|
def on_interaction(self, Player):
|
||||||
Player.statistics.set_hp(self.Statistics.hp)
|
Player.statistics.set_hp(self.Statistics.hp)
|
||||||
Player.statistics.set_stamina(self.Statistics.stamina)
|
Player.statistics.set_stamina(self.Statistics.stamina)
|
||||||
Player.statistics.set_thirst(self.Statistics.thirst)
|
Player.statistics.set_thirst(self.Statistics.thirst)
|
||||||
Player.statistics.set_hunger(self.Statistics.hunger)
|
Player.statistics.set_hunger(self.Statistics.hunger)
|
||||||
|
|
||||||
|
@ -3,6 +3,6 @@ from src.entities.Interactable import Interactable
|
|||||||
|
|
||||||
class Pickupable(Interactable):
|
class Pickupable(Interactable):
|
||||||
def __init__(self, texture, size, pos, Statistics):
|
def __init__(self, texture, size, pos, Statistics):
|
||||||
super().__init__(texture, size, pos)
|
super().__init__(texture, size, pos, Statistics)
|
||||||
self.is_pickupable = True
|
self.is_pickupable = True
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class EventManager:
|
|||||||
if keys[pygame.K_SPACE]:
|
if keys[pygame.K_SPACE]:
|
||||||
object = self.game.map.getEntityOnCoord(self.player.getFacingCoord())
|
object = self.game.map.getEntityOnCoord(self.player.getFacingCoord())
|
||||||
if type(object) is Pickupable:
|
if type(object) is Pickupable:
|
||||||
object.on_pickup(self.player)
|
object.on_interaction(self.player)
|
||||||
self.game.map.removeSpriteFromMap(object)
|
self.game.map.removeSpriteFromMap(object)
|
||||||
if keys[pygame.K_w]:
|
if keys[pygame.K_w]:
|
||||||
self.player.rotate(Rotations.NORTH)
|
self.player.rotate(Rotations.NORTH)
|
||||||
|
Loading…
Reference in New Issue
Block a user