level select timeout
This commit is contained in:
parent
003141b7e4
commit
da22509fe1
38
NS.py
38
NS.py
|
@ -158,8 +158,8 @@ class NS(Game, Animation):
|
|||
{
|
||||
"time":
|
||||
{
|
||||
"int": ["timer-max-time", "timer-start-time", "timer-addition", "sword-delay",
|
||||
"attract-gif-length", "attract-board-length", "attract-reset-countdown"],
|
||||
"int": ["timer-max-time", "timer-start-time", "timer-addition", "sword-delay", "attract-gif-length",
|
||||
"attract-board-length", "attract-reset-countdown", "level-select-reset-countdown"],
|
||||
"float": "timer-warning-start"
|
||||
},
|
||||
"input":
|
||||
|
@ -445,7 +445,7 @@ class NS(Game, Animation):
|
|||
self.reset()
|
||||
|
||||
|
||||
class LevelSelect(GameChild):
|
||||
class LevelSelect(Animation):
|
||||
"""
|
||||
Display the available levels. Initialize a platform for each level and display each platform beneath its level glowing
|
||||
with a pair of pads to press to start that level. Wait for user input, then launch the level of the pair that gets
|
||||
|
@ -453,8 +453,9 @@ class LevelSelect(GameChild):
|
|||
"""
|
||||
|
||||
def __init__(self, parent):
|
||||
GameChild.__init__(self, parent)
|
||||
Animation.__init__(self, parent)
|
||||
self.subscribe(self.respond, KEYDOWN)
|
||||
self.register(self.timeout)
|
||||
y = 250
|
||||
indent = 10
|
||||
dsr = self.get_display_surface().get_rect()
|
||||
|
@ -499,6 +500,7 @@ class LevelSelect(GameChild):
|
|||
self.active = True
|
||||
for platform in self.platforms:
|
||||
platform.activate()
|
||||
self.start_timeout_countdown()
|
||||
|
||||
def deactivate(self):
|
||||
self.active = False
|
||||
|
@ -512,6 +514,7 @@ class LevelSelect(GameChild):
|
|||
for level_index in range(3):
|
||||
self.platforms[level_index].view.unhide()
|
||||
self.previews[level_index].unhide()
|
||||
self.halt()
|
||||
|
||||
def respond(self, event):
|
||||
"""
|
||||
|
@ -539,8 +542,25 @@ class LevelSelect(GameChild):
|
|||
"""
|
||||
self.launch(self.level_index_selected)
|
||||
|
||||
def start_timeout_countdown(self):
|
||||
"""
|
||||
Launch an animation on a delay that will reset the game after the delay. If the countdown is already active, reset the
|
||||
countdown.
|
||||
"""
|
||||
print("start")
|
||||
self.halt(self.timeout)
|
||||
self.play(self.timeout, delay=self.get_configuration("time", "level-select-reset-countdown"), play_once=True)
|
||||
|
||||
def timeout(self):
|
||||
"""
|
||||
Reset to the title screen
|
||||
"""
|
||||
print("timeout")
|
||||
self.get_game().wipe.start(self.get_game().reset, leave_wipe_running=True)
|
||||
|
||||
def update(self):
|
||||
if self.active:
|
||||
Animation.update(self)
|
||||
self.get_game().logo.update()
|
||||
if self.level_index_selected is None:
|
||||
for level_index, platform in enumerate(self.platforms):
|
||||
|
@ -569,6 +589,10 @@ class LevelSelect(GameChild):
|
|||
rect.center = preview.location.center
|
||||
preview.update()
|
||||
self.get_display_surface().blit(frame, rect)
|
||||
# If input in the player's platform detected reset the automatic game reset countdown
|
||||
if self.get_game().platform.get_pressed():
|
||||
print("reset")
|
||||
self.start_timeout_countdown()
|
||||
|
||||
|
||||
class Button(Sprite):
|
||||
|
@ -1193,6 +1217,7 @@ class Wipe(Animation):
|
|||
Animation.__init__(self, parent)
|
||||
self.image = load(self.get_resource("Ink.png")).convert()
|
||||
self.sound = self.get_audio().sfx["wipe"]
|
||||
self.callback_kwargs = {}
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
|
@ -1207,7 +1232,7 @@ class Wipe(Animation):
|
|||
def activate(self):
|
||||
self.active = True
|
||||
|
||||
def start(self, callback):
|
||||
def start(self, callback, **kwargs):
|
||||
"""
|
||||
Trigger the wipe animation to begin. The given callback function will be called when the screen is filled with the
|
||||
wipe graphic.
|
||||
|
@ -1218,6 +1243,7 @@ class Wipe(Animation):
|
|||
self.up = True
|
||||
self.blind_height = self.get_display_surface().get_height() / self.BLIND_COUNT
|
||||
self.callback = callback
|
||||
self.callback_kwargs = kwargs
|
||||
self.play()
|
||||
self.sound.play()
|
||||
|
||||
|
@ -1230,7 +1256,7 @@ class Wipe(Animation):
|
|||
self.blind_height -= self.SPEED
|
||||
if self.blind_height <= 0:
|
||||
self.up = False
|
||||
self.callback()
|
||||
self.callback(**self.callback_kwargs)
|
||||
else:
|
||||
self.blind_height += self.SPEED
|
||||
if self.blind_height >= self.get_display_surface().get_height() / self.BLIND_COUNT:
|
||||
|
|
1
config
1
config
|
@ -61,6 +61,7 @@ sword-delay = 300
|
|||
attract-gif-length = 10000
|
||||
attract-board-length = 3600
|
||||
attract-reset-countdown = 30000
|
||||
level-select-reset-countdown = 30000
|
||||
|
||||
[bgm]
|
||||
title = resource/bgm/title.ogg, .65
|
||||
|
|
2
lib/pgfw
2
lib/pgfw
|
@ -1 +1 @@
|
|||
Subproject commit f5de024ef3627a20191b0a36308ac8ad8a4e6e6c
|
||||
Subproject commit 7329aa76937b5fd225bb561459a2f5c70a57819d
|
|
@ -0,0 +1,9 @@
|
|||
52418 0
|
||||
70979 0
|
||||
78301 0
|
||||
79581 0
|
||||
98128 1
|
||||
100960 1
|
||||
113904 2
|
||||
120571 2
|
||||
122294 2
|
Loading…
Reference in New Issue