From: Neil Date: Sat, 10 Sep 2016 12:00:04 +0000 (+0200) Subject: Actually end the night on timeout. Also end the night if Boyd dies out X-Git-Tag: tabakrolletjie-v1.0.0~112^2~2 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=2345da1ab4f1319448cb14cf077ef492767a9fd7;p=tabakrolletjie.git Actually end the night on timeout. Also end the night if Boyd dies out --- diff --git a/tabakrolletjie/enemies.py b/tabakrolletjie/enemies.py index 59151d5..80a0776 100644 --- a/tabakrolletjie/enemies.py +++ b/tabakrolletjie/enemies.py @@ -26,7 +26,7 @@ MAX_AGE = 60 MAX_ELEMENTS = 400 MAX_HEALTH = 100 -MOULD_STAGES = [10, 20] +MOULD_STAGES = [15, 25] class Mould(pymunk.Body): @@ -186,3 +186,6 @@ class Boyd(object): def render(self, surface): """Draw ourselves""" surface.blit(self._image, (0, 0), None, 0) + + def alive(self): + return len(self._moulds) > 0 diff --git a/tabakrolletjie/scenes/night.py b/tabakrolletjie/scenes/night.py index f9935d3..6d4e2bc 100644 --- a/tabakrolletjie/scenes/night.py +++ b/tabakrolletjie/scenes/night.py @@ -57,20 +57,27 @@ class NightScene(BaseScene): from .menu import MenuScene SceneChangeEvent.post(scene=MenuScene()) if ev.key == pgl.K_e: - from .day import DayScene - SceneChangeEvent.post(scene=DayScene()) + self._to_day() elif ev.type == pgl.MOUSEBUTTONDOWN: if ev.button == 1: self._lights.toggle_nearest(ev.pos, surfpos=True) print self._lights.lit_by(ev.pos, surfpos=True) + def _to_day(self): + # End the night + from .day import DayScene + SceneChangeEvent.post(scene=DayScene()) + @debug_timer("night.tick") def tick(self, gamestate): 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 + else: + self._to_day() + if not self._mould.alive(): + self._to_day() def exit(self, gamestate): turnip_data = [turnip.serialize() for turnip in self._turnips]