'SELECT': (pgl.K_RETURN, pgl.K_KP_ENTER),
'QUIT': (pgl.K_ESCAPE, pgl.K_q),
'SWITCH': (pgl.K_TAB,),
+
+ 'KONAMI': (
+ pgl.K_UP, pgl.K_DOWN, pgl.K_LEFT, pgl.K_RIGHT, pgl.K_a, pgl.K_b),
})
-# PALETTE
+KONAMI_CODE = [
+ pgl.K_UP,
+ pgl.K_UP,
+ pgl.K_DOWN,
+ pgl.K_DOWN,
+ pgl.K_LEFT,
+ pgl.K_RIGHT,
+ pgl.K_LEFT,
+ pgl.K_RIGHT,
+ pgl.K_b,
+ pgl.K_a,
+]
PALETTE = AttrDict({
'BLACK': (0, 0, 0),
if getattr(opts, k, None) is not None:
options[k] = getattr(opts, k)
options['save_location'] = opts.save_location
+ options['cheat_enabled'] = False
def _get_default_save_location():
import pygame.locals as pgl
-from naja.constants import KEYS, PALETTE
+from naja.constants import KEYS, PALETTE, KONAMI_CODE
from naja.events import SceneChangeEvent, QuitGameEvent
+from naja.options import options
from naja.scenes.scene import Scene
from naja.scenes.credits import CreditsScene
from naja.scenes.game import GameScene
quit.add_callback('click', lambda event: QuitGameEvent.post())
selector.add(quit)
+ self.konami = []
+
def scene_callback(self, scene_class):
return lambda event: SceneChangeEvent.post(scene_class)
+ def handle_event(self, ev):
+ if ev.type == pgl.KEYDOWN and self.konami is not None:
+ if ev.key in KEYS.KONAMI:
+ self.konami.append(ev.key)
+ if self.konami == KONAMI_CODE:
+ options['cheat_enabled'] = True
+ print "Cheats enabled."
+ self.konami = None
+ elif self.konami != KONAMI_CODE[:len(self.konami)]:
+ self.konami = None
+ return super(MenuScene, self).handle_event(ev)
+
def handle_scene_event(self, ev):
if ev.type == pgl.KEYDOWN:
if ev.key in KEYS.QUIT: