From: Neil Date: Sun, 28 Feb 2016 19:40:11 +0000 (+0200) Subject: Add very placeholder level scene X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=590f15d78138250a04cc777d645c2ca632b8984a;p=koperkapel.git Add very placeholder level scene --- diff --git a/koperkapel/scenes/level.py b/koperkapel/scenes/level.py new file mode 100644 index 0000000..c29ffc0 --- /dev/null +++ b/koperkapel/scenes/level.py @@ -0,0 +1,23 @@ +"""Render a level""" + +import json + +from pgzero.constants import keys +from .base import Scene, ChangeSceneEvent + + +class LevelScene(Scene): + """ Level scene. """ + + + def __init__(self, level_name): + self._level_name = level_name + + def draw(self, screen): + screen.clear() + screen.draw.text("This is level {}".format(self._level_name), (200, 100)) + + def on_key_down(self, key, mod, unicode): + if key == keys.ESCAPE: + from .menu import MenuScene + return [ChangeSceneEvent(MenuScene())] diff --git a/koperkapel/scenes/menu.py b/koperkapel/scenes/menu.py index dac4402..63e1ba8 100644 --- a/koperkapel/scenes/menu.py +++ b/koperkapel/scenes/menu.py @@ -3,6 +3,7 @@ from pgzero.constants import keys from .base import Scene, ChangeSceneEvent from .credits import CreditsScene +from .level import LevelScene class MenuScene(Scene): @@ -15,3 +16,5 @@ class MenuScene(Scene): def on_key_down(self, key, mod, unicode): if key == keys.C: return [ChangeSceneEvent(CreditsScene())] + if key == keys.L: + return [ChangeSceneEvent(LevelScene('level1'))]