Trying to make a QTE (possible infinite loop exception)
Posted: Mon Sep 20, 2021 1:32 am
I'm currently trying to make a QTE that would let you mash a keyboard key to fill up a bar before a timer bar runs out, but the label game is pretty problematic, it always causes an infinite loop exception no matter how I restructure it T-T
Here's my code with comments below:
Here's my code with comments below:
Code: Select all
transform alpha_dissolve:
alpha 0.0
linear 0.5 alpha 1.0
on hide:
linear 0.5 alpha 0 #this fades the bar
screen mash_meter:
text "[mash_points]/[maxmash]" xalign 0.0 yalign 0.05
bar value mash_points range maxmash xalign 0.0 yalign 0.1 xmaximum 200
screen buzz:
if mash:
key "w" action Jump("plus")
screen countdown(timer_jump, time=20):
timer time repeat False action [ Hide('countdown'), Jump(timer_jump) ]
bar value AnimatedValue(0, time, time, time) at alpha_dissolve
label start:
$ mash = False
$ mash_points = 0
$ maxmash = 10
"Game start! (Press \"w\" key)"
label game:
while mash_points <= 10:
show screen mash_meter
show screen countdown("jump_fail")
$ mash = True
show screen buzz #this causes the exception in this current structure, I've changed up the code in this label many times
if mash_points <= 11 and mash_points >= 9: #had to make it look like this since mash_points == 10 causes the exception too
jump passed
else:
jump game
label plus:
$ mash_points += 1
jump game
label jump_fail:
hide screen mash_meter
hide screen countdown
$ mash = False
"Too slow!"
jump start
label passed:
hide screen buzz
hide screen mash_meter
hide screen countdown
$ mash = False
"You win!"
return