import pygame.locals as pgl
-from .scene import Scene
-from .menu import MenuScene
-
+from naja.events import SceneChangeEvent
+from naja.scenes.scene import Scene
from naja.widgets.board import BoardWidget
from naja.widgets.player_bits import PlayerBitsWidget
from naja.widgets.game_bits import GameBitsWidget
from naja.widgets.info_area import InfoAreaWidget
-from naja.events import SceneChangeEvent
-
class GameScene(Scene):
"""
self.widgets.append(InfoAreaWidget((480, 0)))
def handle_event(self, ev):
+ from naja.scenes.menu import MenuScene
if ev.type == pgl.KEYUP and ev.key in (pgl.K_q, pgl.K_ESCAPE):
SceneChangeEvent.post(MenuScene)
return
from naja.widgets.text import TextWidget
from naja.events import QuitGameEvent
from naja.scenes.credits import CreditsScene
+from naja.scenes.game import GameScene
from naja.events import SceneChangeEvent
colour='white'))
self.widgets.append(TextWidget((10, 70), 'Quit', fontsize=32,
colour='white'))
+ self.pos = 0
def handle_event(self, ev):
- if ev.type == pgl.KEYDOWN and ev.key in (pgl.K_q, pgl.K_ESCAPE):
- QuitGameEvent.post()
- return
- if ev.type == pgl.KEYDOWN and ev.key is pgl.K_RETURN:
- SceneChangeEvent.post(CreditsScene)
- return
+ if ev.type == pgl.KEYDOWN:
+ if ev.key in (pgl.K_q, pgl.K_ESCAPE):
+ QuitGameEvent.post()
+ return
+ if ev.key == pgl.K_DOWN:
+ self.pos = (self.pos + 1) % 3
+ elif ev.key == pgl.K_UP:
+ self.pos = (self.pos - 1) % 3
+ elif ev.key == pgl.K_RETURN:
+ if self.pos == 2:
+ QuitGameEvent.post()
+ return
+ elif self.pos == 0:
+ scene = GameScene
+ elif self.pos == 1:
+ scene = CreditsScene
+ SceneChangeEvent.post(scene)