Fixed Collidable and made pickupable

TODO - make object disappear after pickup
This commit is contained in:
jonspacz 2020-04-04 20:21:37 +02:00
parent 9efad498f7
commit 9b7011a010
3 changed files with 18 additions and 28 deletions

View File

@ -5,27 +5,6 @@ class Collidable(Entity):
def __init__(self, texture, pos, id): def __init__(self, texture, pos, id):
super().__init__(texture, pos, id) super().__init__(texture, pos, id)
self.is_collidable = True
def check_for_collision(self, x_pos, y_pos):
if self.pos[0] == x_pos:
if self.pos[1] == y_pos:
return True
return False
col = Collidable(1, 1, 1)
"""
def interact_with_hp(self, hp, Statistics):
Statistics.set_hp(hp)
def interact_with_hunger(self, hunger, Statistics):
Statistics.set_hunger(hunger)
def interact_with_thirst(self, thirst, Statistics):
Statistics.set_thirst(thirst)
def interact_with_stamina(self, stamina, Statistics):
Statistics.set_stamina(stamina)"""

View File

@ -1,5 +1,16 @@
import src.entities.Interactable as Interactable import src.entities.Interactable as Interactable
from src.entities import Statistics, Player
class Pickupable(Interactable): class Pickupable(Interactable):
pass def __init__(self, texture, pos, id):
super().__init__(texture, pos, id)
self.is_pickupable = True
def on_pickup(self, Player, Statistics):
Player.statistics.set_hp(Statistics.hp)
Player.statistics.set_stamina(Statistics.stamina)
Player.statistics.set_thirst(Statistics.thirst)
Player.statistics.set_hunger(Statistics.hunger)
# TODO delete pickupable object from map

View File

@ -1,9 +1,9 @@
class Statistics: class Statistics:
def __init__(self): def __init__(self, hp, hunger, thirst, stamina):
self.hp = 100 self.hp = hp
self.hunger = 100 self.hunger = hunger
self.thirst = 100 self.thirst = thirst
self.stamina = 100 self.stamina = stamina
# methods that don't let the values pass below 0 and over 100 during change # methods that don't let the values pass below 0 and over 100 during change
def set_hp(self, hp_diff): def set_hp(self, hp_diff):