X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=tabakrolletjie%2Fscenes%2Fday.py;h=cbe0460c4717a86fb15181a1a9f040e0d49457a2;hb=5de2a99cc8756eeb79239ab2d8472e43b7b5fe70;hp=16e2249e5c6fbb32b8007749dbd7cb08227a3934;hpb=30ae643c600f90d917256aecdac5bf0856e256e5;p=tabakrolletjie.git diff --git a/tabakrolletjie/scenes/day.py b/tabakrolletjie/scenes/day.py index 16e2249..cbe0460 100644 --- a/tabakrolletjie/scenes/day.py +++ b/tabakrolletjie/scenes/day.py @@ -17,6 +17,7 @@ from ..obstacles import ObstacleManager from ..events import SceneChangeEvent from ..utils import debug_timer, shadowed_text, write_save_file from ..loader import loader +from ..sound import sound from ..transforms import Overlay, Alpha, ColourWedges from ..constants import SCREEN_SIZE, FONTS, FPS, NIGHT_HOURS_PER_TICK, DEBUG @@ -39,8 +40,10 @@ class DayScene(BaseScene): self._tool = None self._light_colors = None self._dragging = None - # Turnip - self.grow_turnips(gamestate) + # Create Turnips + for turnip_data in gamestate.turnips: + turnip = Turnip(space=self._space, **turnip_data) + self._turnips.append(turnip) # Tools self._light_toolbar = [] self._tools = self.create_tools(gamestate) @@ -88,17 +91,6 @@ class DayScene(BaseScene): (shadowed_text("Press a key to return to the menu", FONTS["sans"], 24), (350, 400))) - def grow_turnips(self, gamestate): - for turnip_data in gamestate.turnips: - turnip = Turnip(space=self._space, **turnip_data) - # Turnips grow at dawn - seeds = turnip.grow() - if seeds: - gamestate.seeds += seeds - gamestate.harvested += 1 - else: - self._turnips.append(turnip) - def create_tools(self, gamestate): tools = [] @@ -111,6 +103,9 @@ class DayScene(BaseScene): tool = ImageButton( '32', '%s.png' % light_config["type"], name='light', pos=(x, y)) + font = loader.load_font(FONTS["sans"], size=12) + tool_cost = font.render("%d" % light_config["cost"], True, (0, 0, 0)) + tool._img.blit(tool_cost, (16, 12), None) tool.light_config = light_config tools.append(tool) x += step @@ -131,14 +126,14 @@ class DayScene(BaseScene): def exit(self, gamestate): self._unset_cursor() - turnip_data = [turnip.serialize() for turnip in self._turnips] - gamestate.turnips = turnip_data def end_day(self, gamestate): if self._ending: return self._battery.apply_recharge() gamestate.update_lights(self._lights) + turnip_data = [turnip.serialize() for turnip in self._turnips] + gamestate.turnips = turnip_data self._ending = True from .night import NightScene SceneChangeEvent.post(scene=NightScene()) @@ -202,8 +197,7 @@ class DayScene(BaseScene): self._turnips.append(turnip) gamestate.seeds -= 1 except TurnipInvalidPosition: - # TODO: Add error sound or something - pass + sound.play_sound("beep_kind.ogg") def _update_light_angle(self, pos, gamestate): # Update the angle of the given light @@ -228,6 +222,7 @@ class DayScene(BaseScene): ev.pos, pygame.display.get_surface()) # Bail if we're too close to an existing light, obstacle or turnip if check_space_for_light(self._space, pos, max_distance=25): + sound.play_sound("beep_kind.ogg") return gamestate.seeds -= cost cfg["position"] = pos