Merge remote-tracking branch 'origin/passingEvents'

This commit is contained in:
Marcin Kostrzewski 2020-04-06 01:01:27 +02:00
commit 998c6c0094
2 changed files with 12 additions and 5 deletions

View File

@ -22,7 +22,7 @@ class EventManager:
def handleEvents(self): def handleEvents(self):
pygame.event.pump() pygame.event.pump()
self.game.screen.ui.timerTextView.changeText(self.game.ingameTimer.getPrettyTime()) self.game.screen.ui.updateTime()
keys = pygame.key.get_pressed() keys = pygame.key.get_pressed()
for event in pygame.event.get(): for event in pygame.event.get():

View File

@ -66,19 +66,19 @@ class Ui():
consoleLines = [] consoleLines = []
if self.healthBar.value != statistics.hp: if self.healthBar.value != statistics.hp:
self.healthBar.updateFill(statistics.hp) self.healthBar.updateFill(statistics.hp)
consoleLines.append("Health: " + str(statistics.hp)) consoleLines.append(self.timer.getPrettyTime() + " - Health: " + str(statistics.hp))
if self.hungerBar.value != statistics.hunger: if self.hungerBar.value != statistics.hunger:
self.hungerBar.updateFill(statistics.hunger) self.hungerBar.updateFill(statistics.hunger)
consoleLines.append("Hunger: " + str(statistics.hunger)) consoleLines.append(self.timer.getPrettyTime() + " - Hunger: " + str(statistics.hunger))
if self.staminaBar.value != statistics.stamina: if self.staminaBar.value != statistics.stamina:
self.staminaBar.updateFill(statistics.stamina) self.staminaBar.updateFill(statistics.stamina)
consoleLines.append("Stamina: " + str(statistics.stamina)) consoleLines.append(self.timer.getPrettyTime() + " - Stamina: " + str(statistics.stamina))
if self.thirstBar.value != statistics.thirst: if self.thirstBar.value != statistics.thirst:
self.thirstBar.updateFill(statistics.thirst) self.thirstBar.updateFill(statistics.thirst)
consoleLines.append("Stamina: " + str(statistics.thirst)) consoleLines.append(self.timer.getPrettyTime() + " - Stamina: " + str(statistics.thirst))
if len(consoleLines) > 0: if len(consoleLines) > 0:
self.console.addLinesToConsoleAndScrollToDisplayThem(consoleLines) self.console.addLinesToConsoleAndScrollToDisplayThem(consoleLines)
@ -91,6 +91,13 @@ class Ui():
elif event.button == 5: elif event.button == 5:
console.writeConsoleLines(console.topWrittenLineInd - 1) console.writeConsoleLines(console.topWrittenLineInd - 1)
def updateTime(self):
self.timerTextView.changeText(self.timer.getPrettyTime())
if self.timer.isItDay():
self.isDayTextView.changeText("Day")
else:
self.isDayTextView.changeText("Night")
class Colors(Enum): class Colors(Enum):
RED = (255, 0, 0) RED = (255, 0, 0)