|
4 | 4 | import pygame |
5 | 5 | from apple import Apple |
6 | 6 | from config import Config |
| 7 | +from energyBar import EnergyBar |
7 | 8 | from food import Food |
8 | 9 | from graphik import Graphik |
9 | 10 | from grass import Grass |
@@ -31,6 +32,7 @@ def __init__(self, graphik: Graphik, config: Config, status: Status, tick: int): |
31 | 32 | self.numApplesEaten = 0 |
32 | 33 | self.numDeaths = 0 |
33 | 34 | self.running = True |
| 35 | + self.energyBar = EnergyBar(self.graphik, self.player) |
34 | 36 |
|
35 | 37 | def initializeLocationWidthAndHeight(self): |
36 | 38 | x, y = self.graphik.getGameDisplay().get_size() |
@@ -269,17 +271,6 @@ def respawnPlayer(self): |
269 | 271 | self.status.set("respawned", self.tick) |
270 | 272 | pygame.display.set_caption(("Roam - " + str(self.currentRoom.getName()))) |
271 | 273 |
|
272 | | - def displayInfo(self): |
273 | | - x, y = self.graphik.getGameDisplay().get_size() |
274 | | - startingX = x/8 |
275 | | - startingY = y/8 |
276 | | - size = 30 |
277 | | - self.displayEnergy(startingX, startingY, size) |
278 | | - |
279 | | - def displayEnergy(self, startingX, startingY, size): |
280 | | - self.graphik.drawText("Energy:", startingX, startingY - size/2, size, self.config.black) |
281 | | - self.graphik.drawText(str(floor((self.player.getEnergy()))), startingX, startingY + size/2, size, self.config.black) |
282 | | - |
283 | 274 | def displayInventoryTopItem(self): |
284 | 275 | x, y = self.graphik.getGameDisplay().get_size() |
285 | 276 | xpos = x - x/8 |
@@ -331,9 +322,9 @@ def run(self): |
331 | 322 | self.graphik.getGameDisplay().fill(self.currentRoom.getBackgroundColor()) |
332 | 323 | self.currentRoom.draw(self.locationWidth, self.locationHeight) |
333 | 324 | self.status.draw() |
| 325 | + self.energyBar.draw() |
334 | 326 |
|
335 | 327 | # display |
336 | | - self.displayInfo() |
337 | 328 | self.displayInventoryTopItem() |
338 | 329 |
|
339 | 330 | # update |
|
0 commit comments