projects
/
naja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make chess puzzle level (Kasparov to F3) winnable.
[naja.git]
/
naja
/
scenes
/
win.py
diff --git
a/naja/scenes/win.py
b/naja/scenes/win.py
index 95d931a0b761227ccdb8822da5a090269658ef37..5acff6e5f8abde20029a5ffe21018e038c0d4f0d 100644
(file)
--- a/
naja/scenes/win.py
+++ b/
naja/scenes/win.py
@@
-5,7
+5,8
@@
Win scene.
import pygame.locals as pgl
from naja.constants import KEYS, PALETTE
import pygame.locals as pgl
from naja.constants import KEYS, PALETTE
-from naja.events import QuitGameEvent
+from naja.events import SceneChangeEvent, LoadGameEvent
+from naja.sound import sound
from naja.scenes.scene import Scene
from naja.widgets.image_box import ImageBox
from naja.widgets.text import TextWidget, TextBoxWidget
from naja.scenes.scene import Scene
from naja.widgets.image_box import ImageBox
from naja.widgets.text import TextWidget, TextBoxWidget
@@
-23,21
+24,30
@@
class WinScene(Scene):
(0, 0), "screens/you_won.png")
self.add(background)
(0, 0), "screens/you_won.png")
self.add(background)
- self.add(TextWidget((50, 50), 'You won!', colour=PALETTE.WHITE))
+ y_offset = 250
+
if self.state.gameboard.has_cheated:
self.add(TextWidget(
if self.state.gameboard.has_cheated:
self.add(TextWidget(
- (50 + 64, 50), 'CHEATER!', colour=PALETTE.ORANGE))
+ (50, y_offset), 'But you\'re a CHEATER!', colour=PALETTE.ORANGE))
+ y_offset += 50
+
self.add(TextBoxWidget(
self.add(TextBoxWidget(
- (50,
100
), '\n\n'.join([
+ (50,
y_offset
), '\n\n'.join([
"You're great.",
"You did well.",
"You should be proud of yourself.",
"You're great.",
"You did well.",
"You should be proud of yourself.",
+ "Press ESC to return to the menu",
]),
colour=PALETTE.WHITE, padding=1, border=1,
bg_colour=PALETTE.BLACK, border_colour=PALETTE.BLACK,
box_width=300))
]),
colour=PALETTE.WHITE, padding=1, border=1,
bg_colour=PALETTE.BLACK, border_colour=PALETTE.BLACK,
box_width=300))
+ sound.play_music('A_ninja.ogg', 0.25)
def handle_scene_event(self, ev):
def handle_scene_event(self, ev):
+ from naja.scenes.menu import MenuScene
if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
- QuitGameEvent.post()
+ sound.stop()
+ # drop current state
+ LoadGameEvent.post(None)
+ SceneChangeEvent.post(MenuScene)
return
return