From 590f15d78138250a04cc777d645c2ca632b8984a Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 28 Feb 2016 21:40:11 +0200 Subject: [PATCH] Add very placeholder level scene --- koperkapel/scenes/level.py | 23 +++++++++++++++++++++++ koperkapel/scenes/menu.py | 3 +++ 2 files changed, 26 insertions(+) create mode 100644 koperkapel/scenes/level.py 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'))] -- 2.34.1