Making a moving bar minigame

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Doeny
Regular
Posts: 145
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Making a moving bar minigame

#1 Post by Doeny »

Hi, I started making a qte minigame, where you need to tap the key with the right timing, as a rectangle lines up in certain area, and gets harder with each attempt. I used come from fable_2_minigame I found on lemmasoft as a base, but can't get it to work, and I'm not even sure if that's the proper way to do it. Can anyone help me with it?

Code: Select all

init 15 python:
    qte_bar = 90
    qte_clicks = 0
    qte_zone_1 = 0
    qte_zone_2 = 0
    qte_score = 0
    qte_hit = False
    qte_speed = 1
    qte_point_pos = 700
    qte_button_pressed = 0
    qte_bar_side = 0
init:
    transform qte_point_move(frp):
        xpos 560 + frp *7
        subpixel True
        ypos qte_point_pos

screen qte_minigame:
    if qte_clicks < 1:
        add "qte_bar1.png" align(0.5, 0.85)
    if qte_clicks < 2:
        add "qte_bar2.png" align(0.5, 0.90)
    if qte_clicks < 3:
        add "qte_bar3.png" align(0.5, 0.95)
    add "qte_point.png" at qte_point_move(qte_bar)
    text "[qte_bar] Bar value" align(0.5,0.2)
    text "[qte_clicked] clicked | [qte_button_pressed] Pressed" align(0.5,0.3)
    text "[qte_hit] hit" align(0.5,0.4)
    text "[qte_point_pos] pos" align (0.5, 0.5)
    text "[qte_bar_side] side" align (0.5, 0.6)

    if qte_clicked < 3:
        key "K_SPACE":
            if qte_button_pressed == 0:
                if qte_bar >= qte_zone_1 and qte_bar <= qte_zone_2:
                    action [SetVariable("qte_clicked", qte_clicked + 1), SetVariable("qte_button_pressed", qte_button_pressed +1), SetVariable("qte_point_pos", qte_point_pos + 60), SetVariable("qte_hit", True), SetVariable("qte_zone_1", qte_zone_1 + 3), SetVariable("qte_zone_1", qte_zone_2 - 3), SetVariable("qte_speed", qte_speed + 0.5), SetVariable("qte_score", qte_score + 1)]
                else:
                    action [SetVariable("qte_clicked", qte_clicked + 1), SetVariable("qte_button_pressed", qte_button_pressed +1), SetVariable("qte_point_pos", qte_point_pos + 60), SetVariable("qte_hit", False), SetVariable("qte_zone_1", qte_zone_1 + 3), SetVariable("qte_zone_1", qte_zone_2 - 3), SetVariable("qte_speed", qte_speed + 0.5)]
            else:
                action NullAction()

screen qte_timer_left:
    timer 0.0001 repeat True action [If(qte_bar > 0, SetVariable("qte_bar", qte_bar - qte_speed)), If(qte_bar <= 0, Hide("qte_timer_left"), Show("qte_timer_right")), If(qte_bar <= 0, SetVariable("qte_button_pressed", 0))]
screen qte_timer_right:
    timer 0.0001 repeat True action [If(qte_bar < 100, SetVariable("qte_bar", qte_bar + qte_speed)), If(qte_bar >= 100, Hide("qte_timer_right"), Show("qte_timer_left")), If(qte_bar >= 100, SetVariable("qte_button_pressed", 0))]

screen qte_timer_main:
    timer 500.0 action Jump("end_minigame")

label start_minigame:
    $ qte_point_pos = 700
    $ qte_clicked = 0
    $ qte_score = 0
    $ qte_zone_1 = 30
    $ qte_zone_2 = 70
    $ qte_speed = 1
    $ qte_button_pressed = 0
    $ qte_bar = renpy.random.randint(1, 99)
    $ qte_bar_side = renpy.random.randint(0, 1)
    if qte_bar_side == 0:
        show screen qte_timer_left
    else:
        show screen qte_timer_right
    show screen qte_timer_main
    call screen qte_minigame


label end_minigame:
    hide screen qte_minigame
    hide screen qte_timer_left
    hide screen qte_timer_right
    $ renpy.pause(0.3)
    jump end #continue game

Post Reply

Who is online

Users browsing this forum: elcharlo, Google [Bot]