Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Need help setting up BOX2D

Author
Message
FERSIS
18
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 14th Jun 2009 06:15
Hi, i was wondering if someone could give me a hand setting up BOX2.
This is what ive tried to do:


I create the floor and 2 boxes with a size of 100x100 px.
But they dont collide correctly (And the rotation is messed up)
To run the code you need a cube.png image of 100x100px
Thanks.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 14th Jun 2009 21:38
For a start, change these lines:


To this:


Secondly, the rotation may be messed up because clockwise/anticlockwise depend on the up direction, and so are application dependent. Try negating the angles you use for dbRotateSprite().

Thirdly, update to the latest version of Box2D, (which means that you will then add shapes to the body rather than the body def)

Fourthly, once you have updated, there will be a command called 'SetMassFromShapes' which you must call after adding shapes to a body.

FERSIS
18
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 14th Jun 2009 22:18 Edited at: 14th Jun 2009 22:26
Thanks Diggsey my #macros were bad. (Bad macro,bad!)
The rotation was messed up because i didnt know about the dbOffsetSprite command...
Again , thanks... have you tought on making a wrapper of BOX2D ?
You know for physics noobs like me
Code fixed:

Login to post a reply

Server time is: 2024-11-25 08:19:01
Your offset time is: 2024-11-25 08:19:01