Skip to content

Commit 249ddb8

Browse files
refactor(examples): tidy timer.rpy
1 parent 05038ff commit 249ddb8

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

game/examples/timer.rpy

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
# https://www.fortunusgames.com/post/timed-choices-code
2-
transform alpha_dissolve:
3-
alpha 0.0
4-
linear 0.5 alpha 1.0
5-
on hide:
6-
linear 0.5 alpha 0
7-
8-
screen countdown:
9-
timer 0.01 repeat True action If(timer_time > 0, true=SetVariable('timer_time', timer_time - 0.01), false=[Hide('countdown'), Jump(timer_jump)])
10-
### ^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)
11-
12-
bar value timer_time range timer_range xalign 0.5 yalign 0.9 xmaximum 300 at alpha_dissolve
13-
# ^This is the timer bar.
14-
152
default timer_time = 0
163
default timer_range = 0
17-
default timer_jump = 'start'
184

19-
label timer:
5+
screen countdown(timer_jump):
6+
timer 0.01:
7+
repeat True
8+
action If(
9+
timer_time > 0,
10+
true = SetVariable('timer_time', timer_time - 0.01),
11+
false=[
12+
Hide('countdown'),
13+
Jump(timer_jump),
14+
]
15+
)
16+
17+
bar value AnimatedValue(timer_time, timer_range):
18+
xalign 0.5
19+
yalign 0.9
20+
xmaximum 300
2021

21-
label menu1:
22+
label timer:
2223

23-
$ timer_time = 3
24-
$ timer_range = 3
25-
$ timer_jump = 'menu1_slow'
24+
$ timer_time = 3
25+
$ timer_range = 3
2626

27-
show screen countdown
27+
show screen countdown("timer_too_slow")
2828

29-
menu:
30-
"End timer":
31-
hide screen countdown
32-
jump start
29+
menu:
30+
"End timer":
31+
hide screen countdown
32+
jump start
3333

34-
label menu1_slow:
34+
label timer_too_slow:
3535

36-
"Did you fall asleep, by any chance?"
36+
"Did you fall asleep, by any chance?"
3737

38-
jump start
38+
jump start

0 commit comments

Comments
 (0)