From a06ce53fc1c4603d33a89a1334aa5687dc0e7e6f Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sun, 5 Apr 2020 23:42:41 +0200 Subject: [PATCH 1/4] Implemented getEntityOnCoord method --- src/game/Map.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/game/Map.py b/src/game/Map.py index a8408d7..e70e439 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) From 7b34e04665de8fbd32dd6eb9152ec08eed4c22cc Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sun, 5 Apr 2020 23:43:15 +0200 Subject: [PATCH 2/4] Fixed syntax --- src/game/Map.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/Map.py b/src/game/Map.py index e70e439..3cbf07f 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -78,7 +78,7 @@ class Map: def getEntityOnCoord(self, coord): result = None for entity in self.collidables: - if entity.rect.x == coord[0] and entity.rect.y == coord[1] + if entity.rect.x == coord[0] and entity.rect.y == coord[1]: result = entity return result From 86d9efe8376761af813006f4a4882f3c8b87bf38 Mon Sep 17 00:00:00 2001 From: jonspacz Date: Sun, 5 Apr 2020 23:43:23 +0200 Subject: [PATCH 3/4] Merge branch 'passingEvents' of C:\Users\Paul\Desktop\DSZI_Survival with conflicts. --- src/game/Game.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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() From 1c287d65d4d4e638daea6274e7da63e41b375d71 Mon Sep 17 00:00:00 2001 From: jonspacz Date: Sun, 5 Apr 2020 23:43:53 +0200 Subject: [PATCH 4/4] fixed statistics --- src/entities/Statistics.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) 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