Skip to content

Commit

Permalink
feat(examples): add timer.rpy
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Sep 1, 2024
1 parent d9e375c commit 05038ff
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions game/examples/start.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ label start:
"Text":
jump text

"Timer":
jump timer

"Tooltip":
jump tooltip

Expand Down
38 changes: 38 additions & 0 deletions game/examples/timer.rpy
Original file line number Diff line number Diff line change
@@ -0,0 +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:

label menu1:

$ timer_time = 3
$ timer_range = 3
$ timer_jump = 'menu1_slow'

show screen countdown

menu:
"End timer":
hide screen countdown
jump start

label menu1_slow:

"Did you fall asleep, by any chance?"

jump start

0 comments on commit 05038ff

Please sign in to comment.