From 28c8033fc20fc71e8a5e39fde868ac3f0ccac374 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 10 Sep 2016 13:47:29 +0200 Subject: [PATCH] Add night length --- tabakrolletjie/constants.py | 3 +++ tabakrolletjie/scenes/night.py | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tabakrolletjie/constants.py b/tabakrolletjie/constants.py index 5529b60..9e10892 100644 --- a/tabakrolletjie/constants.py +++ b/tabakrolletjie/constants.py @@ -17,6 +17,9 @@ SCREEN_SIZE = (1024, 704) # Frame per second FPS = 60 +# Night length in ticks +NIGHT_LENGTH = 3000 + # Pymunk categories OBSTACLE_CATEGORY = 1 << 0 LIGHT_CATEGORY = 1 << 1 diff --git a/tabakrolletjie/scenes/night.py b/tabakrolletjie/scenes/night.py index ff98213..f9935d3 100644 --- a/tabakrolletjie/scenes/night.py +++ b/tabakrolletjie/scenes/night.py @@ -13,6 +13,7 @@ from ..utils import debug_timer from ..loader import loader from ..transforms import Overlay from ..turnip import Turnip +from ..constants import NIGHT_LENGTH class NightScene(BaseScene): @@ -30,6 +31,7 @@ class NightScene(BaseScene): self._turnips.append(turnip) self._soil = loader.load_image( "textures", "soil.png", transform=self.DARKNESS) + self._total_ticks = 0 @debug_timer("night.render") def render(self, surface, gamestate): @@ -64,9 +66,11 @@ class NightScene(BaseScene): @debug_timer("night.tick") def tick(self, gamestate): - self._mould.tick(gamestate, self._space, self._lights) - self._lights.tick() - print "Power usage: ", self._lights.total_power_usage() + if self._total_ticks < NIGHT_LENGTH: + self._mould.tick(gamestate, self._space, self._lights) + self._lights.tick() + print "Power usage: ", self._lights.total_power_usage() + self._total_ticks += 1 def exit(self, gamestate): turnip_data = [turnip.serialize() for turnip in self._turnips] -- 2.34.1