[SOLVED] Point and Click + Timer question!

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
User avatar
Eirrir
Regular
Posts: 81
Joined: Mon Feb 27, 2017 7:16 pm
Projects: Operation: Future Domination
Tumblr: Eirrir
itch: eirrir
Contact:

[SOLVED] Point and Click + Timer question!

#1 Post by Eirrir » Fri Dec 07, 2018 7:55 pm

Hello everyone! I'm working on a game that has some point-and-click elements and would like to be able to add a timed feature for it as well so that players will have a limited time to pick and choose what they want to check out. I'm using an imagemap with hotspots that change the cursor when hovered over and, when pressed on, will jump to other labels. Those labels will call the screen again until every hotspot is checked.

When I "show screen countdown," everything works like it should except that the cursor doesn't change when hovering over the hotspots, which is very crucial! I was wondering if there is some way to tweak the code I have to allow the cursor-hover to work when the timer is shown. I'm not even sure why it's not working the way it should. Any help is greatly appreciated!

Please take a look at the code I have for this:

Code: Select all

define config.mouse = { 'default' : [ ('cursor.png', 0, 0)], 'imagemap' : [ ('qm.png', 0, 0)], 'camera' : [ ('cam_cursor.png', 0, 0)] }

Code: Select all

screen countdown:
    zorder 99
    timer 0.01 repeat True action If(time > 0, true=SetVariable('time', time - 0.01), false=[Hide('countdown'), Jump(timer_jump)])
    style_group "pref"
    bar value time range timer_range style "timerbar"

Code: Select all

screen lh_click: 
    on "hide" action Hide("displayTextScreen")

    imagemap:
        ground "lh_zoom"
        hover  "lh_zoom"
        hotspot (306, 161, 269, 252) clicked [Return("value"), Jump("look_computers")] mouse "imagemap" #hovered [ Play ("test_two", "sfx/camera_beep.ogg")]
        hotspot (109, 481, 255, 173) clicked [Return("value"), Jump("look_table")] mouse "imagemap" #hovered [ Play ("test_two", "sfx/camera_beep.ogg")]
        hotspot (304, 0, 374, 74) clicked [Return("value"), Jump("look_lights")] mouse "imagemap" #hovered [ Play ("test_two", "sfx/camera_beep.ogg")]
        hotspot (725, 124, 333, 181) clicked [Return("value"), Jump("look_windows")] mouse "imagemap" #hovered [ Play ("test_two", "sfx/camera_beep.ogg")]

Code: Select all

    $ time = 4
    $ timer_range = 4
    $ timer_jump = 'scene1_pt1'
    show screen countdown
    call screen lh_click
label look_table:
    $ check_table = True
    "Blah"
    if check_computers == True and check_windows == True and check_table == True and check_lights == True:
        jump scene1_pt1
    else:
        call screen lh_click
label look_lights:
    $ check_lights = True
    "Blah"
    if check_computers == True and check_windows == True and check_table == True and check_lights == True:
        jump scene1_pt1
    else:
        call screen lh_click
label look_computers:
    $ check_computers = True
    "Blah"
    if check_computers == True and check_windows == True and check_table == True and check_lights == True:
        jump scene1_pt1
    else:
        call screen lh_click
label look_windows:
    $ check_windows = True
    "blah"
    if check_computers == True and check_windows == True and check_table == True and check_lights == True:
        jump scene1_pt1
    else:
        call screen lh_click
label scene1_pt1:
    scene lh
    hide screen countdown
Last edited by Eirrir on Mon Dec 10, 2018 2:36 pm, edited 2 times in total.

philat
Eileen-Class Veteran
Posts: 1654
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Point and Click + Timer question!

#2 Post by philat » Sun Dec 09, 2018 9:04 pm

Unsure why the timer would interfere with the cursor, but try using AnimatedValue instead of calling the timer so often.

User avatar
Eirrir
Regular
Posts: 81
Joined: Mon Feb 27, 2017 7:16 pm
Projects: Operation: Future Domination
Tumblr: Eirrir
itch: eirrir
Contact:

Re: Point and Click + Timer question!

#3 Post by Eirrir » Mon Dec 10, 2018 12:48 pm

philat wrote:
Sun Dec 09, 2018 9:04 pm
Unsure why the timer would interfere with the cursor, but try using AnimatedValue instead of calling the timer so often.
Thank you very much for your suggestion! I tried what you said with this new timer code:

Code: Select all

screen countdown:
    zorder 99
    timer time repeat False action [Hide('countdown'), Jump(timer_jump)]
    #style_group "pref"
    bar value AnimatedValue(0, time, time, time) xmaximum 200 xalign 0.5 yalign 0.05
And it indeed fixed the mouse hover issue, but a new problem cropped up. Now, whenever I click on something, the timer would reset to the full time, even though I want the timer to continue the time left off before I clicked the hotspot. Sorry if the way I just explained it is confusing, haha!

User avatar
Per K Grok
Miko-Class Veteran
Posts: 556
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1
Projects: Defenders of Adacan Part 2
Deviantart: pekj
itch: per-k-grok
Location: Sverige
Contact:

Re: Point and Click + Timer question!

#4 Post by Per K Grok » Mon Dec 10, 2018 1:13 pm

Eirrir wrote:
Mon Dec 10, 2018 12:48 pm
And it indeed fixed the mouse hover issue, but a new problem cropped up. Now, whenever I click on something, the timer would reset to the full time, even though I want the timer to continue the time left off before I clicked the hotspot.
I have a different approach to looping a timer.

Code: Select all

label timer:
    $ renpy.pause(delay=0.2, hard=True)
    if vKoll==1:
        jump firstKoll
     elif vKoll==2:
        jump secondKoll
        
label firstKoll:
    [--- do stuff ---] 
    jump timer
It gives the possibility to run 0.2 second loops in which you can update stuff.

I don't know if this is useful for your situation, but it has worked very well for me doing point and click stuff.
Image Visual Story Telling, DeviantArt Group for animations, comics, games and illustrations https://www.deviantart.com/acgi

User avatar
Eirrir
Regular
Posts: 81
Joined: Mon Feb 27, 2017 7:16 pm
Projects: Operation: Future Domination
Tumblr: Eirrir
itch: eirrir
Contact:

Re: Point and Click + Timer question!

#5 Post by Eirrir » Mon Dec 10, 2018 2:36 pm

Thanks for the help, everyone! I tinkered with code a bit and found that the solution is actually pretty simple. I just changed the timer value in my original code from 0.01 to 0.05.

Code: Select all

screen countdown:
    zorder 99
    timer 0.05 repeat True action If(time > 0, true=SetVariable('time', time - 0.05), false=[Hide('countdown'), Jump(timer_jump)])
    style_group "pref"
    bar value time range timer_range style "timerbar"
This has been solved :)
Current VN Project:
Image
Game Development Blog

philat
Eileen-Class Veteran
Posts: 1654
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: [SOLVED] Point and Click + Timer question!

#6 Post by philat » Mon Dec 10, 2018 8:50 pm

Some suggestions. There is zero reason that clicking should reset the timer unless you have something that is manually hiding/reshowing the countdown screen.

Code: Select all

screen countdown:
    zorder 99
    timer time action [Hide('countdown'), Jump(timer_jump)]
    bar value AnimatedValue(0, time, time, time) xmaximum 200 xalign 0.5 yalign 0.05

screen lh_click: 

    imagemap:
        ground # image here
        idle # image here
        hover  # image here
        hotspot (306, 161, 269, 252) action Jump("look_computers") mouse "imagemap" # doesn't seem like you're doing anything with the Return, so you don't need it
        hotspot (109, 481, 255, 173) action Jump("look_table") mouse "imagemap"
        hotspot (304, 0, 374, 74) action Jump("look_lights") mouse "imagemap"
        hotspot (725, 124, 333, 181) action Jump("look_windows") mouse "imagemap"

label start:
    show screen countdown
    call screen lh_click

label look_table:
    $ check_table = True
    "Blah"
    jump scene1_pt1_check

label look_lights:
    $ check_lights = True
    "Blah"
    jump scene1_pt1_check

label look_computers:
    $ check_computers = True
    "Blah"
    jump scene1_pt1_check

label look_windows:
    $ check_windows = True
    "blah"
    jump scene1_pt1_check

label scene1_pt1_check:
    if not (check_computers and check_windows and check_table and check_lights):
        call screen lh_click

label scene1_pt1:
    hide screen countdown
    "Time up / all searched"



Post Reply

Who is online

Users browsing this forum: Andredron, deltadidirac, Google [Bot]