Merge remote-tracking branch 'origin/entities_branch' into Player
This commit is contained in:
commit
3d5c8690ff
@ -1,5 +1,31 @@
|
|||||||
import src.entities.Entity as Entity
|
from src.entities.Entity import Entity
|
||||||
|
|
||||||
|
|
||||||
class Collidable(Entity):
|
class Collidable(Entity):
|
||||||
pass
|
|
||||||
|
def __init__(self, texture, pos, id):
|
||||||
|
super().__init__(texture, pos, id)
|
||||||
|
|
||||||
|
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)"""
|
@ -1,5 +1,6 @@
|
|||||||
class Entity:
|
class Entity:
|
||||||
def __init__(self):
|
|
||||||
self.texture
|
def __init__(self, texture, pos, id):
|
||||||
self.pos
|
self.texture = texture
|
||||||
self.id
|
self.pos = pos
|
||||||
|
self.id = id
|
||||||
|
@ -1,5 +1,24 @@
|
|||||||
import src.entities.Entity as Entity
|
from src.entities.Entity import Entity
|
||||||
|
|
||||||
|
|
||||||
class Interactable(Entity):
|
class Interactable(Entity):
|
||||||
pass
|
|
||||||
|
def __init__(self, texture, pos, id):
|
||||||
|
super().__init__(texture, pos, id)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def interact_with_hp(hp, Statistics):
|
||||||
|
Statistics.set_hp(hp)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def interact_with_hunger(hunger, Statistics):
|
||||||
|
Statistics.set_hunger(hunger)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def interact_with_thirst(thirst, Statistics):
|
||||||
|
Statistics.set_thirst(thirst)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def interact_with_stamina(stamina, Statistics):
|
||||||
|
Statistics.set_stamina(stamina)
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import src.entities.Collidable as Collidable
|
from src.entities.Collidable import Collidable
|
||||||
|
from src.entities.Interactable import Interactable
|
||||||
|
|
||||||
|
|
||||||
class Npc(Collidable):
|
class Npc(Collidable, Interactable):
|
||||||
def __init__(self):
|
def __init__(self, texture, pos, id, path, speed):
|
||||||
self.path
|
Collidable.__init__(self, texture, pos, id)
|
||||||
self.speed
|
Interactable.__init__(self, texture, pos, id)
|
||||||
|
self.path = path
|
||||||
|
self.speed = speed
|
||||||
|
@ -1,6 +1,46 @@
|
|||||||
class Statistics:
|
class Statistics:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.hp
|
self.hp = 100
|
||||||
self.hunger
|
self.hunger = 100
|
||||||
self.thirst
|
self.thirst = 100
|
||||||
self.stamina
|
self.stamina = 100
|
||||||
|
|
||||||
|
# methods that don't let the values pass below 0 and over 100 during change
|
||||||
|
def set_hp(self, hp_diff):
|
||||||
|
if 0 <= self.hp + hp_diff <= 100:
|
||||||
|
self.hp = self.hp + hp_diff
|
||||||
|
else:
|
||||||
|
if self.hp + hp_diff <= 0:
|
||||||
|
self.hp = 0
|
||||||
|
else:
|
||||||
|
self.hp = 100
|
||||||
|
|
||||||
|
def set_hunger(self, hunger_diff):
|
||||||
|
if 0 <= self.hp + hunger_diff <= 100:
|
||||||
|
self.hp = self.hp + hunger_diff
|
||||||
|
else:
|
||||||
|
if self.hp + hunger_diff <= 0:
|
||||||
|
self.hp = 0
|
||||||
|
else:
|
||||||
|
self.hp = 100
|
||||||
|
|
||||||
|
def set_thirst(self, thirst_diff):
|
||||||
|
if 0 <= self.hp + thirst_diff <= 100:
|
||||||
|
self.hp = self.hp + thirst_diff
|
||||||
|
else:
|
||||||
|
if self.hp + thirst_diff <= 0:
|
||||||
|
self.hp = 0
|
||||||
|
else:
|
||||||
|
self.hp = 100
|
||||||
|
|
||||||
|
def set_stamina(self, stamina_diff):
|
||||||
|
if 0 <= self.hp + stamina_diff <= 100:
|
||||||
|
self.hp = self.hp + stamina_diff
|
||||||
|
else:
|
||||||
|
if self.hp + stamina_diff <= 0:
|
||||||
|
self.hp = 0
|
||||||
|
else:
|
||||||
|
self.hp = 100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user