• Box2D Assistance
    5 replies, posted
Dear god this library is going to give me a migraine, could someone explain to me how the world boundaries work? (upperBounds, lowerBounds). What would I set them to for say 320, 240 window? This whole API is confusing as fuck, I want my pixel units back. [editline]02:32PM[/editline] I keep reading that 100, 100 and -100, -100 should be enough, since it's in meters and all, but all my shit freezes in less than 100 pixels and I have no idea what's going on. Tear. [editline]02:35PM[/editline] Nevermind, figured it out. Rate me dumb.
Don't feel too bad, I always seem to ask for help right before I figure it out too :smile:
Thanks :) Though I still despise Box2D with a fiery passion, time to just do my own simple physics.
Anyway, I know you said you figured it out, but for the benefit of anyone reading this at least, you have to treat your simulation world and your window as separate coordinate planes, and then simply multiply your simulation coords by the ratio of sim world size to window size when you render. [editline]05:38PM[/editline] automerge
The thing is, physics engines don't work in pixels. They usually work in meters. So you might make some rule that 100 pixels = 1 meter. Then when you make 1 meter objects in Box2D, you draw them as 100 pixels. This is your graphics:physics scale. Don't think in pixels anymore, think in meters. Let the graphics do there thing separately.
Well it's not even that anymore. Just some of the coord stuff in it bothers me, about setting boxes, why do I have to provide half-height, and half-width. Why can't I just make a simple rectangle and tell it to collide with that?
Sorry, you need to Log In to post a reply to this thread.