import pygame.locals as pgl
from naja.constants import KEYS
-from naja.events import SceneChangeEvent
+from naja.events import SceneChangeEvent, finish_event
+from naja.options import options
from naja.scenes.scene import Scene
+from naja.sound import sound
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.widgets.robot import RobotWidget
-from naja.sound import sound
class GameScene(Scene):
def handle_scene_event(self, ev):
from naja.scenes.menu import MenuScene
- if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
- SceneChangeEvent.post(MenuScene)
- return
+ if ev.type == pgl.KEYDOWN:
+ if ev.key in KEYS.QUIT:
+ SceneChangeEvent.post(MenuScene)
+ return
+ if options.cheat_enabled:
+ if ev.key == pgl.K_0:
+ self.state.player.bits.toggle_bit(0)
+ elif ev.key == pgl.K_1:
+ self.state.player.bits.toggle_bit(1)
+ elif ev.key == pgl.K_2:
+ self.state.player.bits.toggle_bit(2)
+ elif ev.key == pgl.K_3:
+ self.state.player.bits.toggle_bit(3)
+ elif ev.key == pgl.K_4:
+ self.state.player.bits.toggle_bit(4)
+ elif ev.key == pgl.K_5:
+ self.state.player.bits.toggle_bit(5)
+ elif ev.key == pgl.K_6:
+ self.state.player.bits.toggle_bit(6)
+ elif ev.key == pgl.K_7:
+ self.state.player.bits.toggle_bit(7)
+ return finish_event()