Merge remote-tracking branch 'origin/passingEvents' into passingEvents
This commit is contained in:
commit
cfd3b05981
@ -28,9 +28,14 @@ class Player(Entity):
|
|||||||
|
|
||||||
def getFacingCoord(self):
|
def getFacingCoord(self):
|
||||||
if self.rotation == Rotations.NORTH:
|
if self.rotation == Rotations.NORTH:
|
||||||
return (0, -1)
|
return self.rect.x, self.rect.y - (self.rect.h)
|
||||||
elif self.rotation == Rotations.SOUTH:
|
elif self.rotation == Rotations.SOUTH:
|
||||||
pass
|
return self.rect.x, self.rect.y + (self.rect.h)
|
||||||
|
elif self.rotation == Rotations.EAST:
|
||||||
|
return self.rect.x + (self.rect.h), self.rect.y
|
||||||
|
elif self.rotation == Rotations.WEST:
|
||||||
|
return self.rect.x - (self.rect.h), self.rect.y
|
||||||
|
|
||||||
# Returns given statistic
|
# Returns given statistic
|
||||||
def getStatistic(self, stat):
|
def getStatistic(self, stat):
|
||||||
if stat.value == StatisticNames.HP:
|
if stat.value == StatisticNames.HP:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
|
from src.entities.Pickupable import Pickupable
|
||||||
from src.entities.Player import Rotations
|
from src.entities.Player import Rotations
|
||||||
|
|
||||||
# Player can move every given milliseconds
|
# Player can move every given milliseconds
|
||||||
@ -38,7 +39,11 @@ class EventManager:
|
|||||||
def handlePlayerControls(self, keys):
|
def handlePlayerControls(self, keys):
|
||||||
# Key names are temporary
|
# Key names are temporary
|
||||||
# TODO: Load key bindings from JSON
|
# TODO: Load key bindings from JSON
|
||||||
|
if keys[pygame.K_SPACE]:
|
||||||
|
object = self.game.map.getEntityOnCoord(self.player.getFacingCoord())
|
||||||
|
if type(object) is Pickupable:
|
||||||
|
object.on_pickup(self.player)
|
||||||
|
self.game.map.removeSpriteFromMap(object)
|
||||||
if keys[pygame.K_w]:
|
if keys[pygame.K_w]:
|
||||||
self.player.rotate(Rotations.NORTH)
|
self.player.rotate(Rotations.NORTH)
|
||||||
if not self.game.map.collision(self.player.rect.x, self.player.rect.y - self.player.rect.w):
|
if not self.game.map.collision(self.player.rect.x, self.player.rect.y - self.player.rect.w):
|
||||||
|
14
src/ui/Ui.py
14
src/ui/Ui.py
@ -63,10 +63,24 @@ class Ui():
|
|||||||
font=self.font)
|
font=self.font)
|
||||||
|
|
||||||
def updateBasedOnPlayerStats(self, statistics: Statistics):
|
def updateBasedOnPlayerStats(self, statistics: Statistics):
|
||||||
|
consoleLines = []
|
||||||
|
if self.healthBar.value != statistics.hp:
|
||||||
self.healthBar.updateFill(statistics.hp)
|
self.healthBar.updateFill(statistics.hp)
|
||||||
|
consoleLines.append("Health: " + str(statistics.hp))
|
||||||
|
|
||||||
|
if self.hungerBar.value != statistics.hunger:
|
||||||
self.hungerBar.updateFill(statistics.hunger)
|
self.hungerBar.updateFill(statistics.hunger)
|
||||||
|
consoleLines.append("Hunger: " + str(statistics.hunger))
|
||||||
|
|
||||||
|
if self.staminaBar.value != statistics.stamina:
|
||||||
self.staminaBar.updateFill(statistics.stamina)
|
self.staminaBar.updateFill(statistics.stamina)
|
||||||
|
consoleLines.append("Stamina: " + str(statistics.stamina))
|
||||||
|
|
||||||
|
if self.thirstBar.value != statistics.thirst:
|
||||||
self.thirstBar.updateFill(statistics.thirst)
|
self.thirstBar.updateFill(statistics.thirst)
|
||||||
|
consoleLines.append("Stamina: " + str(statistics.thirst))
|
||||||
|
|
||||||
|
self.console.addLinesToConsoleAndScrollToDisplayThem(consoleLines)
|
||||||
|
|
||||||
def updateBasedOnPygameEvent(self, event: pygame.event):
|
def updateBasedOnPygameEvent(self, event: pygame.event):
|
||||||
pass
|
pass
|
||||||
|
@ -13,6 +13,7 @@ class UiBar(UiElement):
|
|||||||
self.outlineColor = outlineColor
|
self.outlineColor = outlineColor
|
||||||
self.outlineThickness = outlineThickness
|
self.outlineThickness = outlineThickness
|
||||||
self.filledBarColor = filledBarColor
|
self.filledBarColor = filledBarColor
|
||||||
|
self.value = initialFilledPercent
|
||||||
|
|
||||||
self.__genBar__()
|
self.__genBar__()
|
||||||
|
|
||||||
@ -27,4 +28,5 @@ class UiBar(UiElement):
|
|||||||
|
|
||||||
def updateFill(self, filledPercent):
|
def updateFill(self, filledPercent):
|
||||||
self.filledPercent = filledPercent / 100
|
self.filledPercent = filledPercent / 100
|
||||||
|
self.value = filledPercent
|
||||||
self.__genBar__()
|
self.__genBar__()
|
||||||
|
Loading…
Reference in New Issue
Block a user