pin point precision and sprite placement

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
Eatrentpie
Newbie
Posts: 9
Joined: Fri Jan 02, 2015 6:41 am
Contact:

pin point precision and sprite placement

#1 Post by Eatrentpie »

I am working on a mini game and would like to match my sprite placement to predetermined screen coordinates that I have figured out from a background image. unfortunately the coordinates on the image don't match those on the image . there appear to be MARGINS that such that renpy seems to insist that 0,0 is actually quite a ways from the screen it's not going from the center either so I can't navigate from that. anybody got any clue how I can get renpy to rever to a traditional x,y coordinate system
[edited for further description]
I'm using the sprite manager to place the sprites
Last edited by Eatrentpie on Fri Jan 10, 2020 4:36 am, edited 1 time in total.

User avatar
VimislikArt
Regular
Posts: 90
Joined: Sun Mar 06, 2016 6:50 pm
Projects: King of the Cul-De-Sac
Deviantart: vimislikart
itch: vimislikart
Location: Rochester, NY
Contact:

Re: pin point precision and sprite placement

#2 Post by VimislikArt »

When you're setting your transform properties, add the statement "subpixel True". This changes how Ren'py interprets the value behind xpos and ypos. You may have to adjust the xanchor and yanchor values depending on how you were calculating the positioning (I think ren'py defaults to the top left of images, so this applies to the xpos and ypos as well).

For instance, this would move the image 500 pixels to the right, and 300 pixels down, but based on the bottom left of the image.

Code: Select all

show exampleimage:
	subpixel True xpos 500 ypos 300 yanchor 1.0
Check out my VN, King of the Cul-De-Sac, currently in Open Beta production! Try it out HERE!

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
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-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: pin point precision and sprite placement

#3 Post by Per K Grok »

Eatrentpie wrote: Thu Jan 02, 2020 10:15 pm I am working on a mini game and would like to match my sprite placement to predetermined screen coordinates that I have figured out from a background image. unfortunately the coordinates on the image don't match those on the image . there appear to be MARGINS that such that renpy seems to insist that 0,0 is actually quite a ways from the screen it's not going from the center either so I can't navigate from that. anybody got any clue how I can get renpy to rever to a traditional x,y coordinate system
I almost exclusively place my sprites using xpos and ypos, and I don't recognize this problem.

I often use a screen like this to check positions in the screen in-game.

Code: Select all

default mx=0
default my=0

screen showPos():
    text str(mx) + ":" + str(my)

    timer 0.05 action [SetVariable("mx",renpy.get_mouse_pos()[0]), SetVariable("my", renpy.get_mouse_pos()[1])] repeat True


label start:
    show screen showPos

If you use this do you experience the margin effect?

One possible explanation of the "margin effect" could be that the image contains more "empty space" around your character than you take into the consideration. Possibly the image top left corner is at the screen 0,0 but there is space in between the character and the screen sides because there are "empty space" in the image.

Eatrentpie
Newbie
Posts: 9
Joined: Fri Jan 02, 2015 6:41 am
Contact:

Re: pin point precision and sprite placement

#4 Post by Eatrentpie »

I'm using the spritemanager so not sure if the above suggestions will work.
it's the same thing that runs the stars in the starfield demo.

actually I know that wont work.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: pin point precision and sprite placement

#5 Post by gas »

Check the code to verify the SpriteManager got no borders.
The SpriteManager can define an area of rendering, and coordinates of Sprites are relative to that, not the entire screen.
Posting the code here should help.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

Eatrentpie
Newbie
Posts: 9
Joined: Fri Jan 02, 2015 6:41 am
Contact:

Re: pin point precision and sprite placement

#6 Post by Eatrentpie »

no borders are ever defined at initialization and the manager uses the entire 1920 by 1080 screen it just places things funny

Post Reply

Who is online

Users browsing this forum: Google [Bot]