Modify in 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
Gianserpe
Newbie
Posts: 21
Joined: Mon May 27, 2019 4:20 pm
Contact:

Modify in minigame

#1 Post by Gianserpe »

Hello to all. I wanted to introduce a minigame in my vn in which I have to hit targets when they pass through the viewfinder.
To make this minigame I based on a minigame already present here (shooting game).
This is the code.
In this game the target images keep scrolling until a shot is fired, only then is label hunting called again.
I would like to modify the code so that, once the target is on the screen, it immediately calls the label hunting, without having to press on $ ui.imagebutton
Anyone have an idea how this can be done?
I put the attached minigame at the bottom

Code: Select all

define e = Character('Frank', color="#c8ffc8")
define m = Character('Me', color="#c8c8ff")
image bg beached = "images/beached.jpg"
image frank:
    "images/frank.png"
    zoom 1.3

label start:
    
    scene bg beached
    show frank

    e "Hey, are you ready?."
    
    m "Sure I will be right back."
    
    call begin_hunt
    
    scene bg beached
    show frank
    
    if targets_hit == 0:
        e "You didn't hit anyone, I am going to find someone else."
        scene black with dissolve
    if targets_hit > 0:
        e "[targets_hit] of your shots ended up killing someone. Good job"
        scene black with dissolve
    

    "game over"

    return

image target:
    "hunt/target.png"
    zoom 0.5

transform moving_target:
    ypos 275
    linear 3.0 xpos 2000
    xpos -300
    repeat

label begin_hunt:

    $ shots_fired = 0
    $ targets_hit = 0
    call hunting
    return

label hunting:

    scene black
    show target at moving_target
    $ position = At(ImageReference("target"), moving_target)
    show expression position

    $ ui.imagebutton("hunt/crosshair.png", "hunt/crosshair_focused.png", clicked = ui.returns("fired"), xpos= 996, ypos = 163)
    $ fired_gun = ui.interact()

    show expression position
    if position.xpos > 950:
        if position.xpos < 1100:
            with vpunch
            "You Hit. "
            $ shots_fired = shots_fired + 1
            $ targets_hit = targets_hit + 1
            if shots_fired >= 3:
                return
            call hunting

    with vpunch
    "You Missed. "
    $ shots_fired = shots_fired + 1
    if shots_fired >= 3:
                return

    call hunting
    return
Attachments
Shooting Game.rar
(1.27 MiB) Downloaded 25 times

Post Reply

Who is online

Users browsing this forum: konimyun