From: Simon Cross Date: Sat, 10 Sep 2016 16:51:03 +0000 (+0200) Subject: Add infobar and battery manager to night. X-Git-Tag: tabakrolletjie-v1.0.0~74 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=c4b45ee9ae3e1f7b73b306c61a520945379cd16e;p=tabakrolletjie.git Add infobar and battery manager to night. --- diff --git a/tabakrolletjie/scenes/night.py b/tabakrolletjie/scenes/night.py index 7d028d5..99b903b 100644 --- a/tabakrolletjie/scenes/night.py +++ b/tabakrolletjie/scenes/night.py @@ -6,7 +6,9 @@ import pygame.locals as pgl import pymunk from .base import BaseScene +from ..battery import BatteryManager from ..lights import LightManager +from ..infobar import InfoBar from ..obstacles import ObstacleManager from ..enemies import Boyd from ..events import SceneChangeEvent @@ -26,6 +28,8 @@ class NightScene(BaseScene): self._space = pymunk.Space() self._obstacles = ObstacleManager(self._space, gamestate) self._lights = LightManager(self._space, gamestate) + self._battery = BatteryManager(gamestate) + self._infobar = InfoBar("day", battery=self._battery, scene=self) self._mould = Boyd(gamestate, self._space) self._turnips = [] for turnip_data in gamestate.turnips: @@ -44,11 +48,20 @@ class NightScene(BaseScene): tools = [] y = SCREEN_SIZE[1] - 40 tools.append(ImageButton( - '32', 'pause.png', name='pause play', pos=(SCREEN_SIZE[0] - 150, y))) + '32', 'pause.png', name='pause play', + pos=(SCREEN_SIZE[0] - 150, y))) tools.append(ImageButton( '32', 'exit.png', name='exit', pos=(SCREEN_SIZE[0] - 50, y))) return tools + @property + def turnip_count(self): + return len(self._turnips) + + @property + def power_usage(self): + return int(self._lights.total_power_usage()) + @debug_timer("night.render") def render(self, surface, gamestate): surface.blit(self._soil, (0, 0)) @@ -67,6 +80,7 @@ class NightScene(BaseScene): self._lights.render_light(surface) self._obstacles.render(surface) self._lights.render_fittings(surface) + self._infobar.render(surface, gamestate) for tool in self._tools: tool.render(surface)