From: Jeremy Thurgood Date: Fri, 16 May 2014 20:05:24 +0000 (+0200) Subject: Toggle bits when cheats are enabled. X-Git-Tag: 0.1~193 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=9eb2c4febb7e86a2c16dc55fcd1ca30066882d2c;p=naja.git Toggle bits when cheats are enabled. --- diff --git a/naja/scenes/game.py b/naja/scenes/game.py index b50065f..dda5e1e 100644 --- a/naja/scenes/game.py +++ b/naja/scenes/game.py @@ -5,14 +5,15 @@ Gameboard scene. 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): @@ -32,6 +33,25 @@ 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()