Merge remote-tracking branch 'origin/passingEvents' into passingEvents

# Conflicts:
#	data/mapdata/mapEntities.json
This commit is contained in:
Wirus 2020-04-06 00:03:06 +02:00
commit e8e9cca0bb
7 changed files with 51 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

View File

@ -13,7 +13,6 @@
"hunger" : 20 "hunger" : 20
} }
}, },
{ {
"name" : "cranberry", "name" : "cranberry",
"position" : { "position" : {
@ -51,5 +50,19 @@
"y": 9 "y": 9
}, },
"isPickupable" : false, "isPickupable" : false,
},
{
"name" : "rock",
"position" : {
"x": 13,
"y": 1
},
"isPickupable" : false,
"effect" : {
"hp" : 0,
"stamina" : 0,
"thirst" : 0,
"hunger" : 0
}
} }
] ]

View File

@ -30,7 +30,7 @@ class Player(Entity):
if self.rotation == Rotations.NORTH: if self.rotation == Rotations.NORTH:
return (0, -1) return (0, -1)
elif self.rotation == Rotations.SOUTH: elif self.rotation == Rotations.SOUTH:
pass
# Returns given statistic # Returns given statistic
def getStatistic(self, stat): def getStatistic(self, stat):
if stat.value == StatisticNames.HP: if stat.value == StatisticNames.HP:

View File

@ -21,6 +21,8 @@ class EventManager:
def handleEvents(self): def handleEvents(self):
pygame.event.pump() pygame.event.pump()
self.game.screen.ui.timerTextView.changeText(self.game.ingameTimer.getPrettyTime())
keys = pygame.key.get_pressed() keys = pygame.key.get_pressed()
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.QUIT: if event.type == pygame.QUIT:

View File

@ -50,7 +50,7 @@ class Map:
entity["effect"]["thirst"], entity["effect"]["thirst"],
entity["effect"]["stamina"]))) entity["effect"]["stamina"])))
else: else:
actualEntities.append(Entity(entity["name"], actualEntities.append(Entity(entity["name"] + ".jpg",
self.tileSize, self.tileSize,
(entity["position"]["x"] * self.tileSize, entity["position"]["y"] * self.tileSize))) (entity["position"]["x"] * self.tileSize, entity["position"]["y"] * self.tileSize)))
except KeyError: except KeyError:

View File

@ -26,26 +26,37 @@ class Ui():
self.timerTextView = UiText(pygame.Rect(0, 0, leftUiWidth, self.barHeight), font=self.font, self.timerTextView = UiText(pygame.Rect(0, 0, leftUiWidth, self.barHeight), font=self.font,
text=timer.getPrettyTime(), textColor=Colors.WHITE.value, text=timer.getPrettyTime(), textColor=Colors.WHITE.value,
backgroundColor=Colors.GRAY.value) backgroundColor=Colors.GRAY.value)
self.isDayTextView = UiText(pygame.Rect(0, self.timerTextView.rect.y + self.barHeight, leftUiWidth, self.barHeight), text="Day", self.isDayTextView = UiText(
font=self.font, backgroundColor=Colors.GRAY.value, textColor=Colors.WHITE.value) pygame.Rect(0, self.timerTextView.rect.y + self.barHeight, leftUiWidth, self.barHeight), text="Day",
font=self.font, backgroundColor=Colors.GRAY.value, textColor=Colors.WHITE.value)
self.healthTextView = UiText(pygame.Rect(0, 0, rightUiWidth, self.barHeight), text="Health points", self.healthTextView = UiText(pygame.Rect(0, 0, rightUiWidth, self.barHeight), text="Health points",
font=self.font, textColor=Colors.WHITE.value) font=self.font, textColor=Colors.WHITE.value)
self.healthBar = UiBar(pygame.Rect(0, self.healthTextView.rect.y + self.barHeight, rightUiWidth, self.barHeight)) self.healthBar = UiBar(
pygame.Rect(0, self.healthTextView.rect.y + self.barHeight, rightUiWidth, self.barHeight))
self.hungerTextView = UiText(pygame.Rect(0, self.healthBar.rect.y + self.barHeight, rightUiWidth, self.barHeight), self.hungerTextView = UiText(
text="Hunger", font=self.font, textColor=Colors.WHITE.value) pygame.Rect(0, self.healthBar.rect.y + self.barHeight, rightUiWidth, self.barHeight),
self.hungerBar = UiBar(pygame.Rect(0, self.hungerTextView.rect.y + self.barHeight, rightUiWidth, self.barHeight), initialFilledPercent=0, text="Hunger", font=self.font, textColor=Colors.WHITE.value)
filledBarColor=Colors.YELLOW.value) self.hungerBar = UiBar(
pygame.Rect(0, self.hungerTextView.rect.y + self.barHeight, rightUiWidth, self.barHeight),
initialFilledPercent=0,
filledBarColor=Colors.YELLOW.value)
self.staminaTextView = UiText(pygame.Rect(0, self.hungerBar.rect.y + self.barHeight, rightUiWidth, self.barHeight), text="Stamina", self.staminaTextView = UiText(
font=self.font, textColor=Colors.WHITE.value) pygame.Rect(0, self.hungerBar.rect.y + self.barHeight, rightUiWidth, self.barHeight), text="Stamina",
self.staminaBar = UiBar(pygame.Rect(0, self.staminaTextView.rect.y + self.barHeight, rightUiWidth, self.barHeight), filledBarColor=Colors.GREEN.value) font=self.font, textColor=Colors.WHITE.value)
self.staminaBar = UiBar(
pygame.Rect(0, self.staminaTextView.rect.y + self.barHeight, rightUiWidth, self.barHeight),
filledBarColor=Colors.GREEN.value)
self.thirstTextView = UiText(pygame.Rect(0, self.staminaBar.rect.y + self.barHeight, rightUiWidth, self.barHeight), text="Thirst", self.thirstTextView = UiText(
font=self.font, textColor=Colors.WHITE.value) pygame.Rect(0, self.staminaBar.rect.y + self.barHeight, rightUiWidth, self.barHeight), text="Thirst",
self.thirstBar = UiBar(pygame.Rect(0, self.thirstTextView.rect.y + self.barHeight, rightUiWidth, self.barHeight), initialFilledPercent=0, font=self.font, textColor=Colors.WHITE.value)
filledBarColor=Colors.BLUE.value) self.thirstBar = UiBar(
pygame.Rect(0, self.thirstTextView.rect.y + self.barHeight, rightUiWidth, self.barHeight),
initialFilledPercent=0,
filledBarColor=Colors.BLUE.value)
self.console = UiConsole(pygame.Rect(0, self.timerTextView.rect.h + self.isDayTextView.rect.h, leftUiWidth, self.console = UiConsole(pygame.Rect(0, self.timerTextView.rect.h + self.isDayTextView.rect.h, leftUiWidth,
screenHeight - self.timerTextView.rect.h - self.isDayTextView.rect.h), screenHeight - self.timerTextView.rect.h - self.isDayTextView.rect.h),
@ -61,8 +72,6 @@ class Ui():
pass pass
class Colors(Enum): class Colors(Enum):
RED = (255, 0, 0) RED = (255, 0, 0)
GREEN = (0, 255, 0) GREEN = (0, 255, 0)

View File

@ -24,3 +24,11 @@ class UiText(UiElement):
self.image.fill(backgroundColor) self.image.fill(backgroundColor)
wordImage = self.font.render(text, antialias, textColor) wordImage = self.font.render(text, antialias, textColor)
self.image.blit(wordImage, (0, 0)) self.image.blit(wordImage, (0, 0))
def changeText(self, newText):
self.text = newText
if self.backgroundColor is not None:
self.image.fill(self.backgroundColor)
wordImage = self.font.render(self.text, self.antialias, self.textColor)
self.image.blit(wordImage, (0, 0))