Getting the X, Y position of a moving image on the screen

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.
Message
Author
User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Getting the X, Y position of a moving image on the scree

#16 Post by PyTom » Sun Dec 12, 2010 1:45 am

You would implement a timer separately. Something like:

Code: Select all

screen timed_part:
    bar value AnimatedValue(old_value=0.0, value=1.0, delay=3.0)
    timer 3.0 action Jump("failed")

label start:
    "..."

    show screen timed_part

    "Think fast! If you don't click, you will fail!"

    hide screen timed_part

    "Whew!"

    return

label failed:

    "You failed!"

    return
(The code isn't tested, but it gives you the idea.)

That being said, timed segments are generally a bad idea. People may have different levels of language skills, and so read at different speeds - do you really want to punish them just because they're trying to work in a new language? Similarly, some people might be distracted at an inopportune moment because their child is shouting "No!", which to a one year old is a word that they've learned their parents say when they're about to do something naughty, and so they might as well save their parent the trouble, as the naughty thing is going to happen anyway*. Those people might not appreciate having to go back to replay a timed segment.



* Any resemblance to actual children is purely coincidental.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Glazed Donuts
Regular
Posts: 121
Joined: Thu Aug 12, 2010 11:47 am
Contact:

Re: Getting the X, Y position of a moving image on the scree

#17 Post by Glazed Donuts » Sun Dec 12, 2010 12:05 pm

Thank you, PyTom! This was exactly what I was trying to do!! And no, there is no dialogue for the timer I was trying to make. It was a mini game where they have to click objects on the screen in a limited time. THANK YOU SO MUCH!!

I noticed that this affects only the default bar. Can this be used for the custom autobar? I tried doing something like this but I get an error:

Code: Select all

ui.autobar value AnimatedValue(old_value=0.0, value=1.0, delay=10.0)
and I tried to place your code in the block that contains my custom autobar image information, but there are still errors.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Getting the X, Y position of a moving image on the scree

#18 Post by PyTom » Sun Dec 12, 2010 12:16 pm

That's not the right syntax. Can you post your code, and I'll turn it into a screen?
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Glazed Donuts
Regular
Posts: 121
Joined: Thu Aug 12, 2010 11:47 am
Contact:

Re: Getting the X, Y position of a moving image on the scree

#19 Post by Glazed Donuts » Sun Dec 12, 2010 12:25 pm

Actually, I think I found out what I was doing wrong. I had to put this in my custom autobar script:

Code: Select all

ui.autobar(100, old_score, score, 10.0, left_bar=Frame("1.png", 5, 5), right_bar=Frame("2.png", 5, 5) , thumb="3.png", xmaximum=100 ) #it takes 10 seconds for the gauge to fill up
Then in the 'show screen timed_part' block, I put:

Code: Select all

show screen timed_part
$score = 100
"Think fast! If you don't click, you will fail!"
hide screen timed_part
and the gauge was moving slowly enough so that when 10 seconds hit, it was full. Is this an efficient way to do it?

EDIT: Also, another question (sorry!) It seems the only way for this to work correctly is for me to have text show up (Like the 'Think fast' line you used in the example). Is there a way for the timer to go without the text popping up?

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Getting the X, Y position of a moving image on the scree

#20 Post by PyTom » Sun Dec 12, 2010 1:05 pm

You could alway use a pause, or some other way of causing an interaction without showing text.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Glazed Donuts
Regular
Posts: 121
Joined: Thu Aug 12, 2010 11:47 am
Contact:

Re: Getting the X, Y position of a moving image on the scree

#21 Post by Glazed Donuts » Sun Dec 12, 2010 1:17 pm

Adding the $renpy.pause() function works, however, the timer stops once the mouse button is clicked anywhere on the screen. What I was trying to do was to have the user be able to interact on the screen during the 10 seconds, so they can click on things and the timer is visible on the top of the screen that shows how much time they have to interact with it until it goes to another screen. I hope that makes sense.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Hojoo