Making a basic custom position

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
Nova Alamak
Regular
Posts: 71
Joined: Sun Jun 08, 2014 1:45 pm
Contact:

Making a basic custom position

#1 Post by Nova Alamak »

I've followed the documentation and checked the tutorial and since no one is asking this question on the forum, I must be missing something implicit. All I want to do is use absolute position (integers) to show an image at a certain point on screen. I anticipated that in the future I would reuse this position so I made a custom one like to documentation suggests:

Code: Select all

    transform gate:
        xpos 143.0 
        ypos 238.0
Later, I placed an image with

Code: Select all

    show hudra poiseddistant at gate
The image exists, is declared, matches up fine, no errors. But the image isn't shown. What am I doing wrong?

Nova Alamak
Regular
Posts: 71
Joined: Sun Jun 08, 2014 1:45 pm
Contact:

Re: Making a basic custom position

#2 Post by Nova Alamak »

Never mind, figured it out sorta. I'll just put the position every time with Position(xpos= etc. Turns out that doesn't work unless you define anchors. Shouldn't the defaults be 0,0?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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: Making a basic custom position

#3 Post by PyTom »

Your problem is you want to use integers, but you're giving a floating point number. Unlike in math, in Python and Ren'Py, those are different types. Try:

Code: Select all

transform gate:
    xpos 143
    ypos 238
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
fluxus
Regular
Posts: 133
Joined: Thu Jun 19, 2014 8:06 am
Projects: Animal Anaesthesia (a teaching game)
Contact:

Re: Making a basic custom position

#4 Post by fluxus »

Uhm.
I'm pretty sure PyTom means you to try

Code: Select all

transform gate:
    xpos 143
    ypos 238
The thing with floating-point and integers in Ren'Py screen positioning is that integers will be interpreted as an absolute position like you're expecting, while floating point numbers will be interpreted as relative positions; xpos 0.5 is the horizontal center of the screen, for example, regardless of whether you have 1024x768 or 800x600 as your screen resolution.

I'm not sure what xpos 143.0 would actually do.
Maybe it's regarded as out-of-bounds since it's above 1.0.
Then again, since characters can enter from outside the screen, perhaps it is actually drawn, off-screen.
A question for Ren'Py philosophers to ponder :]


Edit due to PyTom's follow-up: Philosophical question, solved. I feel like we're being spoiled, here :)
Last edited by fluxus on Thu Sep 11, 2014 8:53 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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: Making a basic custom position

#5 Post by PyTom »

Through the magic of editing my posts, I'm now saying what I mean.

143.0 actually has a well-define meaning. It's 143 times the width of the enclosing area from the left side of the enclosing area. If the enclosing area is the whole screen, it's 142 screens off the right side of the screen.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

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