Adding JBox2d to existing project

Discuss issues specific the Java port of Box2D
hal9000
Posts: 2
Joined: Sat Jul 05, 2014 4:32 am
Location: South Australia

Adding JBox2d to existing project

Postby hal9000 » Sat Jul 05, 2014 5:14 am

Hi,

(edit: I'm going to try the maven part of this https://code.google.com/p/jbox2d/wiki/Q ... r_Releases )
Sorry for what must be a nube question you see every day.

My Aim - Short Version:
Is there a tutorial for adding JBox2d to an existing project?
I'd like to retain the Testbed UI if possible.

Long Version:
I have successfully written and run my own test class as part of the org.jbox2d.testbed.tests package.
My project is a Top-down maze with Agents interacting with each other running simple A.I (re-written from my BerkeleyX A.I course).
I need a physics engine, and rather leave that to the experts.
I don't need much of a user interface, but it would be nice to watch the Agents move about and interact.
Also would be nice to have Agent movements constrained by walls, other Agents etc.
My project is an Eclipse Maven project.

I'm guessing I need something like a "Hello world" example that includes the Testbed UI.

Is JBox2d the best choice for a Java Physics Engine?

Best Wishes.

hal9000
Posts: 2
Joined: Sat Jul 05, 2014 4:32 am
Location: South Australia

Re: Adding JBox2d to existing project

Postby hal9000 » Sat Jul 05, 2014 8:11 am

Okay I managed to get JBox2d and the Testbed Jars added to my project and running a simple TestbedTest.

Oddities:
1) If I don't override the step() method my test Body goes to sleep and can't be dragged by the mouse.

Code: Select all

    @Override
    public synchronized void step(TestbedSettings settings) {
        super.step(settings);
        setCamera(someBody.getPosition());
    }


2) If I drag the Body with the mouse, the vertical component is flipped. e.g. I need to drag down-right if I want the Body to go up-right.
I'm on a Mac (10.9.3) with Java 1.7.60, JBox2d 2.2.1.1. I thought it might be Mac's "natural scrolling" but changing that setting didn't have any effect.

Suggestions very welcome.

Kind regards.


Return to “Java”



Who is online

Users browsing this forum: No registered users and 1 guest