From 249ddb8cd1c0727db014804f4faff75c9a553d13 Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 1 Sep 2024 12:02:52 -0400 Subject: [PATCH] refactor(examples): tidy timer.rpy --- game/examples/timer.rpy | 54 ++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/game/examples/timer.rpy b/game/examples/timer.rpy index 8cf0209..3ae1a59 100644 --- a/game/examples/timer.rpy +++ b/game/examples/timer.rpy @@ -1,38 +1,38 @@ # https://www.fortunusgames.com/post/timed-choices-code -transform alpha_dissolve: - alpha 0.0 - linear 0.5 alpha 1.0 - on hide: - linear 0.5 alpha 0 - -screen countdown: - timer 0.01 repeat True action If(timer_time > 0, true=SetVariable('timer_time', timer_time - 0.01), false=[Hide('countdown'), Jump(timer_jump)]) - ### ^this code decreases variable time by 0.01 until time hits 0, at which point, the game jumps to label timer_jump (timer_jump is another variable that will be defined later) - - bar value timer_time range timer_range xalign 0.5 yalign 0.9 xmaximum 300 at alpha_dissolve - # ^This is the timer bar. - default timer_time = 0 default timer_range = 0 -default timer_jump = 'start' -label timer: +screen countdown(timer_jump): + timer 0.01: + repeat True + action If( + timer_time > 0, + true = SetVariable('timer_time', timer_time - 0.01), + false=[ + Hide('countdown'), + Jump(timer_jump), + ] + ) + + bar value AnimatedValue(timer_time, timer_range): + xalign 0.5 + yalign 0.9 + xmaximum 300 - label menu1: +label timer: - $ timer_time = 3 - $ timer_range = 3 - $ timer_jump = 'menu1_slow' + $ timer_time = 3 + $ timer_range = 3 - show screen countdown + show screen countdown("timer_too_slow") - menu: - "End timer": - hide screen countdown - jump start + menu: + "End timer": + hide screen countdown + jump start - label menu1_slow: +label timer_too_slow: - "Did you fall asleep, by any chance?" + "Did you fall asleep, by any chance?" - jump start + jump start