elif SceneChangeEvent.matches(ev):
self.change_scene(ev.scene)
else:
+ print(ev.type)
self._scene.handle_event(ev)
self._scene.render(self._surface)
pygame.display.flip()
--- /dev/null
+"""
+Main menu scene.
+"""
+
+import pygame.locals as pgl
+
+from naja.scenes.scene import Scene
+from naja.widgets.text import TextWidget
+from naja.events import SceneChangeEvent
+
+
+class CreditsScene(Scene):
+
+ base_menu = None
+
+ def __init__(self):
+ super(CreditsScene, self).__init__()
+ self.widgets.append(TextWidget((10, 10), 'Credits',
+ colour=(255, 255, 255)))
+
+ def set_base_menu(self, base_menu):
+ self.base_menu = base_menu
+
+ def handle_event(self, ev):
+ if ev.type == pgl.KEYUP and ev.key in (pgl.K_q, pgl.K_ESCAPE):
+ SceneChangeEvent.post(self.base_menu)
+ return
from naja.scenes.scene import Scene
from naja.widgets.text import TextWidget
from naja.events import QuitGameEvent
-
+from naja.scenes.credits import CreditsScene
+from naja.events import SceneChangeEvent
class MenuScene(Scene):
def __init__(self):
super(MenuScene, self).__init__()
- self.widgets.append(TextWidget((10, 10), 'Haai',
+ self.widgets.append(TextWidget((10, 10), 'Naja',
colour=(255, 255, 255)))
+ self.credits_menu = CreditsScene()
+ self.credits_menu.set_base_menu(self)
def handle_event(self, ev):
if ev.type == pgl.KEYUP and ev.key in (pgl.K_q, pgl.K_ESCAPE):
QuitGameEvent.post()
return
+ if ev.type == pgl.KEYUP and ev.key is pgl.K_RETURN:
+ SceneChangeEvent.post(self.credits_menu)
+ return