diff --git a/src/entities/Statistics.py b/src/entities/Statistics.py index c506eee..4c0a507 100644 --- a/src/entities/Statistics.py +++ b/src/entities/Statistics.py @@ -16,29 +16,29 @@ class Statistics: self.hp = 100 def set_hunger(self, hunger_diff): - if 0 <= self.hp + hunger_diff <= 100: - self.hp = self.hp + hunger_diff + if 0 <= self.hunger + hunger_diff <= 100: + self.hunger = self.hunger + hunger_diff else: - if self.hp + hunger_diff <= 0: - self.hp = 0 + if self.hunger + hunger_diff <= 0: + self.hunger = 0 else: - self.hp = 100 + self.hunger = 100 def set_thirst(self, thirst_diff): - if 0 <= self.hp + thirst_diff <= 100: - self.hp = self.hp + thirst_diff + if 0 <= self.thirst + thirst_diff <= 100: + self.thirst = self.thirst + thirst_diff else: - if self.hp + thirst_diff <= 0: - self.hp = 0 + if self.thirst + thirst_diff <= 0: + self.thirst = 0 else: - self.hp = 100 + self.thirst = 100 def set_stamina(self, stamina_diff): - if 0 <= self.hp + stamina_diff <= 100: - self.hp = self.hp + stamina_diff + if 0 <= self.stamina + stamina_diff <= 100: + self.stamina = self.stamina + stamina_diff else: - if self.hp + stamina_diff <= 0: - self.hp = 0 + if self.stamina + stamina_diff <= 0: + self.stamina = 0 else: - self.hp = 100 + self.stamina = 100 diff --git a/src/game/Game.py b/src/game/Game.py index ed1f267..86e1643 100644 --- a/src/game/Game.py +++ b/src/game/Game.py @@ -6,8 +6,10 @@ from os import path from game.EventManager import EventManager from game.Screen import Screen from game.Map import Map + +from src.entities.Pickupable import Pickupable from src.entities.Player import Player -from src.game.Timer import Timer +from src.entities.Statistics import Statistics class Game: @@ -38,11 +40,6 @@ class Game: print("The screen cannot be in a vertical orientation. Exiting...") exit(1) - # Initialize timers - self.pgTimer = pygame.time.Clock() - self.ingameTimer = Timer() - self.ingameTimer.startClock() - self.screen = Screen(self, self.config["window"]) print("OK") @@ -52,13 +49,11 @@ class Game: self.map.addEntity(self.player) self.eventManager = EventManager(self, self.player) + self.mainLoop() def mainLoop(self): while self.running: - # Update ingame clock - self.ingameTimer.updateTime(self.pgTimer.tick()) - self.eventManager.handleEvents() self.spritesList.draw(self.screen.pygameScreen) pygame.display.flip() diff --git a/src/game/Map.py b/src/game/Map.py index a8408d7..3cbf07f 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -1,8 +1,8 @@ import json import pygame -from game.TerrainTile import TerrainTile -from game.Screen import Locations +from src.game.TerrainTile import TerrainTile +from src.game.Screen import Locations from src.entities.Entity import Entity from src.entities.Pickupable import Pickupable @@ -75,6 +75,13 @@ class Map: self.screen.draw(object, Locations.MAP, 0, 0) self.collidables.add(object) + def getEntityOnCoord(self, coord): + result = None + for entity in self.collidables: + if entity.rect.x == coord[0] and entity.rect.y == coord[1]: + result = entity + return result + def addEntity(self, entity): self.screen.draw(entity, Locations.MAP, 0, 0) self.collidables.add(entity)