Stopping at the right time minigame (Solved)

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
morrris
Newbie
Posts: 11
Joined: Fri Jun 21, 2019 3:05 am
Contact:

Stopping at the right time minigame (Solved)

#1 Post by morrris » Sun Sep 18, 2022 4:20 am

Hey kind people,
I was thinking of making a short minigame: Imagine a 20sec timer with millisecs to that infinitely goes in loop from 0.00 to 10.00 and the player wins if he clicks between 07.50 and 09.50. (Yes, it will be an easy minigame).
I'd prefer if I didn't use screens.
Thank you in advance.
Last edited by morrris on Sun Sep 18, 2022 9:08 am, edited 1 time in total.

User avatar
enaielei
Regular
Posts: 114
Joined: Fri Sep 17, 2021 2:09 am
Tumblr: enaielei
Deviantart: enaielei
Github: enaielei
Skype: enaielei
Soundcloud: enaielei
itch: enaielei
Discord: enaielei#7487
Contact:

Re: Stopping at the right time minigame

#2 Post by enaielei » Sun Sep 18, 2022 4:38 am

Code: Select all

screen test(time=10.0):
    default ctime = 0.0
    default interval = 0.5

    timer interval repeat True action SetScreenVariable("ctime", min(ctime + interval, time))

    button:
        action Return(ctime)
        xfill True
        yfill True

    text "[ctime]"

    if ctime == time:
        timer 0.01 action Return(ctime)

label start:
    call screen test()
    if _return >= 7.50 and _return <= 9.50:
        "Passed"
    else:
        "Failed"
Last edited by enaielei on Sun Sep 18, 2022 5:36 am, edited 1 time in total.

morrris
Newbie
Posts: 11
Joined: Fri Jun 21, 2019 3:05 am
Contact:

Re: Stopping at the right time minigame

#3 Post by morrris » Sun Sep 18, 2022 4:43 am

18 minutes? What took you so long? lol

Incredible! Let me try something else: I want a million bucks!

Thank you so much!

morrris
Newbie
Posts: 11
Joined: Fri Jun 21, 2019 3:05 am
Contact:

Re: Stopping at the right time minigame

#4 Post by morrris » Sun Sep 18, 2022 5:03 am

#enaielei
Unfortunately the timer is stuck at 0.0 but I'll try to fix it too. Thanx again.

User avatar
enaielei
Regular
Posts: 114
Joined: Fri Sep 17, 2021 2:09 am
Tumblr: enaielei
Deviantart: enaielei
Github: enaielei
Skype: enaielei
Soundcloud: enaielei
itch: enaielei
Discord: enaielei#7487
Contact:

Re: Stopping at the right time minigame

#5 Post by enaielei » Sun Sep 18, 2022 5:31 am

I never really bothered testing the code, sorry for that.
I had one mistake here.

Code: Select all

timer interval repeat True action SetScreenVariable("ctime", min(ctime + interval, ctime))
It should be...

Code: Select all

timer interval repeat True action SetScreenVariable("ctime", min(ctime + interval, time))
time not ctime.

morrris
Newbie
Posts: 11
Joined: Fri Jun 21, 2019 3:05 am
Contact:

Re: Stopping at the right time minigame

#6 Post by morrris » Sun Sep 18, 2022 7:51 am

It's perfect! Thx again.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot]