projects
/
tabakrolletjie.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add available lights list to levels.
[tabakrolletjie.git]
/
tabakrolletjie
/
scenes
/
night.py
diff --git
a/tabakrolletjie/scenes/night.py
b/tabakrolletjie/scenes/night.py
index d8f0e1a53144d9993734644cb3d5bc65d37abce7..6b42f6bf878dafad72ef01fc63077230c71cc8b4 100644
(file)
--- 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 ..loader import loader
from ..transforms import Overlay
from ..turnip import Turnip
+from ..constants import NIGHT_LENGTH, DEBUG
class NightScene(BaseScene):
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._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):
@debug_timer("night.render")
def render(self, surface, gamestate):
@@
-54,18
+56,28
@@
class NightScene(BaseScene):
if ev.key in (pgl.K_q, pgl.K_ESCAPE):
from .menu import MenuScene
SceneChangeEvent.post(scene=MenuScene())
if ev.key in (pgl.K_q, pgl.K_ESCAPE):
from .menu import MenuScene
SceneChangeEvent.post(scene=MenuScene())
- if ev.key == pgl.K_e:
- from .day import DayScene
- SceneChangeEvent.post(scene=DayScene())
+ if ev.key == pgl.K_e and DEBUG:
+ 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)
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):
@debug_timer("night.tick")
def tick(self, gamestate):
- self._mould.tick(gamestate, self._space, self._lights)
- self._lights.tick()
+ 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()
+ 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]
def exit(self, gamestate):
turnip_data = [turnip.serialize() for turnip in self._turnips]