Replies: 1 comment
-
OK, decided just to copy Godot. ;) Seems like it works good so far. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm making a pixel perfect renderer for Bevy and I have to figure out how to handle the origins of the sprites and the camera. Key questions are in bold.
For instance, when you place a camera, does the
Position
component of the camera refer to the center of the camera or the top-left of the camera? The center seems the most useful. Position the camera on what you want to look at. But in pixel perfect things get a little more sensitive. What's the center pixel of a camera with an odd numbered width or height? The rounded down x/y position of the width and height divided by two?You face the same question with the origin for the sprites. Should the sprites' origin be the top left or the center?
I could do these either way, but what would be the most nice to use design?
I feel like centering the the origins of both the camera and the sprites makes the most sense. The camera really should be centered I feel because that way you can have the height of the camera fixed and automatically extend the width based on the aspect ratio of the screen. With sprites, though, I'm not sure if the centered origin would make it more difficult to do the math to figure out where the bottom of the sprite is, for instance if you wanted a side scroller sprite's feet to perfectly touch the ground.
Just looking to get opinions on the design direction and maybe somebody who has experience writing pixel perfect games could weigh in with their experience or something. 🙂
Looking at Godot there is an "anchor mode" for the camera and "centered" and "offset" options for sprites. That's actually feeling like a good option. That let's the person using it choose what makes the most sense for them.
Another question: Is the +x=right and +y=down coordinates a good standard?
It seems like copying Godot is probably a good idea in this case 😄
Beta Was this translation helpful? Give feedback.
All reactions