Hello again! I'm back with more questions about creating a minigame with Renpy as I've been experimenting with ways to make a QTE more challenging. This time I want to make it so that if the player misses the target (clicks the wrong spot on the screen) they lose a life and after three misses, the minigame ends and they have to start over.
I've added a button that is a transparent image behind the moving target covering the whole screen. Whenever the player clicks this "button" (which is anything outside the target hit box) they add a value to the "miss" variable. My first issue is that after 3 misses ($ miss==3) nothing happens and the game continues. How do I make it so that when $miss==3, the script jumps to my "death" label (or just ends in general)?
I've also added three heart images to the screen as a visual representation of the lives the player has. How do I make it so that after each miss, a heart is hidden from the screen? I've tried to use a series of if statements like this;
if miss==1:
hide image "images/heart_3.png"
But this also does nothing and the hearts stay on screen.
Please help me figure this out, I would greatly appreciate it!!
Code: Select all
screen target_scr(tgt_align, t):
# animated timer
bar value AnimatedValue(0, t, t, t) bar_invert True xsize 300 align (0.95, 0.05)
button:
image "transparent.png"
action SetVariable("miss", If(miss<3,miss+1,3))
imagebutton:
auto "target_%s.png"
action [Hide("target_scr"), Return(1)] # hide the screen by its name
align tgt_align
sensitive not game_over # clickable if game is not over
image "heart_1.png":
xpos -25
ypos -50
image "heart_2.png":
xpos -25
ypos 275
image "heart_3.png":
xpos -25
ypos 600
if not game_over:
timer t action [Jump("too_sloww")]
screen minigame_scr():
text "score: [score]" align (0.5, 0.05)
label savegold(targets_number, game_time):
label try_againn:
pass
$ targets_left = targets_number
show qte scoreboard
show screen minigame_scr
while targets_left > 0: # show targets while we have them
show screen target_scr(tgt_align=( renpy.random.randint(2, 8)*0.1, renpy.random.randint(2, 8)*0.1 ), t=game_time)
$ ui.interact() # waits for player interaction
$ score += 1
$ targets_left -= 1
if score==10:
jump rescue
###################################################
# THIS PART OF THE CODE DOESN'T WORK BUT I LEFT IT IN TO SHOW YOU WHAT
#IM TRYING TO DO
if miss==3:
hide image "images/heart_1.png"
if miss==2:
hide image "images/heart_2.png"
if miss==1:
hide image "images/heart_3.png"
####################################################
label rescue:
pyr "\"Wow you're fast!\""
hide screen minigame_scr
hide qte scoreboard
jump gold
label death:
"Oh no! You ded."
hide screen minigame_scr
hide qte scoreboard
hide screen target_scr
$ score = 0
$ game_over = False
menu:
"Retry":
jump try_againn
label too_sloww:
$ game_over = True
pyr "\"Too slow...\""
hide screen minigame_scr
hide qte scoreboard
hide screen target_scr
$ score = 0
$ game_over = False
menu:
"Retry":
jump try_againn
# "...":
# pass
call savegold(10,5.0
)