Skip to content

Commit

Permalink
refactor(examples): tidy timer.rpy
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Sep 1, 2024
1 parent 05038ff commit 249ddb8
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions game/examples/timer.rpy
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 249ddb8

Please sign in to comment.