Could someone give me a quick tutorial on using world vs local coordinates?
Never done it before so just curious about where to even start. Once I can get going I can play with it and figure it out.
If I have a world that is set to X=2000, Y=2000. How does local coordinates relate to that?
If I set a body to 300,200 on the screen, is that world coordinates? Or local coordinates and then how do I relate that to world coordinates? It seems that a 3rd element needs to be there somewhere in what piece of the world is currently on screen, ie, a camera. Am I completely off base?
Need help w/ World vs Local coordinates
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Need help w/ World vs Local coordinates
I haven't used the physics library a lot, however I do now that in your example those are WORLD coordinates.
I always thought local coordinates are those in the objects itself, so the shape relative to the body.
I always thought local coordinates are those in the objects itself, so the shape relative to the body.
Re: Need help w/ World vs Local coordinates
So maybe I'm confusing local coordinates with screen coordinates which would make absolute sense. If that is the case, how do I translate world coordinates to screen coordinates?
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Need help w/ World vs Local coordinates
Well.. world coordinates - where the "viewport" begins.
If you have your 2000x2000 world and the screen is 800x600, you have to display only a certain part (or scale down), so if the topleft corner starts at coordinate (300, 450) you will get worldx - 300, worldy - 450.
Some pseudo-code: (xoffset and yoffset are the point in the world where the topleft corner of the screen is, and a is the object)
I hope you understand this, if you don't... I'll need to start learning to interact with people instead of computers ![Razz :P](./images/smilies/ms-razz.png)
If you have your 2000x2000 world and the screen is 800x600, you have to display only a certain part (or scale down), so if the topleft corner starts at coordinate (300, 450) you will get worldx - 300, worldy - 450.
Some pseudo-code: (xoffset and yoffset are the point in the world where the topleft corner of the screen is, and a is the object)
Code: Select all
a = bodyshapethingy
love.graphics.draw(a, a:getX() - xoffset, a:getY() - yoffset)
![Razz :P](./images/smilies/ms-razz.png)
Who is online
Users browsing this forum: Google [Bot] and 0 guests