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