## Did you find the SimpleTestbed useful?

Yes
7
78%
No
2
22%
Maybe
0

vernon
Prole
Posts: 18
Joined: Fri Oct 07, 2011 3:54 pm

### Box2D SimpleTestbed. UPDATE: Version 1.0

This is the project I've started working on.
Box2D on C++ has a great Testbed application, where you can quite easily add new physics environments to test out.
You don't need to use placeholder graphics or anything, because the Testbed renders the bodies, shapes, joints etc.

The main goal is to be able to test Lua/LÖVE based Box2D code, not just C++.

The original has a lot of features, and I probably won't port all of those.
My first aim is to get the rendering right with LÖVE's graphics tools and to be able to switch between simulations.

I hope this will be useful for everyone who's struggling with testing box2D's features.

Edit:
first prototype is ready. No camera yet. Thanks for Boolsheet on the IRC channel for the debugging

Edit:
version 0.2
working GUI (except for the time step button and update frequency slider)
camera controls: arrow keys, keypad + - buttons for zooming. Mouse: wheels zoom, right button drags the screen. You can redefine any of the keyboard controls in your own test!
more advanced drawing: now correctly draws all the shapes. Bounding box drawing was added. Joint drawing was added. Coordinate system toggleable

edit:
version 0.21 bugfixes. Fixed Jansen walker, and I fixed the other tests too. Fixed drawing of angled shapes.

edit:
version 1.0 Added features: better drawing algorithm, mousejoint to manipulate objects, Time Stepping capabilities.

Controls:
arrow keys: they move the camera around
right click drag: moves the environment around
left click on shape, drag: it creates a mousejoint between a dynamic body and the cursor's position. It applies a force to the body.

inherit a class from my Test class and save it in a lua file. The name of the class and the filename must match. Put your lua file in the tests directory. Tadaaa!
For more details check out the source of the default tests. Especially: tests/spherestack.lua
Attachments
SimpleTestbed_1.0_mod.love
He refactored the code and made some features better.
SimpleTestbed_1.0.love
version 1.0
Last edited by vernon on Sat Jul 28, 2012 10:17 pm, edited 9 times in total.

Roland_Yonaba
Inner party member
Posts: 1562
Joined: Tue Jun 21, 2011 6:08 pm
Contact:

### Re: Box2D SimpleTestbed

That would be awasome. Actually I never used love.physiscs module, but such a tool will be appreciated.
Much thanks!

Party member
Posts: 223
Joined: Sun Mar 04, 2012 2:04 pm
Location: USA

### Re: Box2D SimpleTestbed

This is great, thank you.

vernon
Prole
Posts: 18
Joined: Fri Oct 07, 2011 3:54 pm

### Re: Box2D SimpleTestbed. UPDATE: Version 0.2

New 0.2 version is out.

vernon
Prole
Posts: 18
Joined: Fri Oct 07, 2011 3:54 pm

### Re: Box2D SimpleTestbed. UPDATE: Version 0.21

Version 0.21

Now everything works correctly.

-time step change
-updating the game world step by step
-mouse joint force effects on the world objects
-more detailed drawing of the different kind of joints
-drawing of contact points
-drawing of friction forces

There is still a lot of features missing, but the testbed can be used for actual testing. Have fun using it

vernon
Prole
Posts: 18
Joined: Fri Oct 07, 2011 3:54 pm

### Re: Box2D SimpleTestbed. UPDATE: Version 1.0

Version 1.0 is done.

I worked so much on this this week that I kinda hate it now lol.
Have fun using it

Party member
Posts: 223
Joined: Sun Mar 04, 2012 2:04 pm
Location: USA

### Re: Box2D SimpleTestbed. UPDATE: Version 1.0

Hey I really like your testbed so I refactored the code a bit, and made it a little cleaner (in my opinion). Also a camera system with proper zooming works now instead of scaling everything manually and better coordinates drawing. Pretty useful when I just want dump a quick box2d test. Thanks a lot!
Attachments
SimpleTestbed_1.0_mod.love

vernon
Prole
Posts: 18
Joined: Fri Oct 07, 2011 3:54 pm

### Re: Box2D SimpleTestbed. UPDATE: Version 1.0

the new coordinates look cool.

well I kinda started with attaching the camera but I couldn't figure out how to keep it from messing up the lines. then i started doing the manual scaling madness.

Code: Select all

love.graphics.setLineWidth(1/camera.sx) 
well this line of yours is pretty smart lol. It didn't came to mind that i could set it under 1 pixel. hehe. then the zoom brings it back to 1.

can you explain what hardoncollider does in the project? just providing the shape class for the improved camera?

edit:
oh so you are the maker of hump? i read the docs on your github. Now i understand it.

Ref
Party member
Posts: 687
Joined: Wed May 02, 2012 11:05 pm

### Re: Box2D SimpleTestbed. UPDATE: Version 1.0

The right click - drag works as expected.
The arrow keys seem to be reversed.
Is that intentional?
Just seems couter-intuitive.

vernon
Prole
Posts: 18
Joined: Fri Oct 07, 2011 3:54 pm

### Re: Box2D SimpleTestbed. UPDATE: Version 1.0

that just wasn't thought through properly by me.

the right mouse click drags the world, while the arrow keys move the camera around. can be fixed by negating two numbers.

### Who is online

Users browsing this forum: No registered users and 2 guests