Box2D physic racer

  ... tutorials on how to use AndEngine.

Box2D physic racer

Postby myfknoll » Wed Mar 19, 2014 3:35 pm

Hello community,

i'm currently developing a race game with andengine and box2d. :extension:
Based on the example here:
i created a simple demo in the AndEngineExamples.

In this example (TopDownRaceGameActivity.class) , the car was replaced by a own class ( Vehicle.class) and has 4 Wheels, each connected with a joint.
In fact i had big problems to find the correct physic data, (forces, mass, speed), only the 2 front wheels are powered.

To reach an independet mass of the texture size, i set the massdata manually.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  2. MassData data = mCarBody.getMassData();
  3.  data.mass = 3.9f;
  4.  mCarBody.setMassData(data);
Parsed in 0.012 seconds, using GeSHi

Why 3.9? Because it worked ;) But you can try out yourself

The IVehicle control is a interface, to control the car. :controller:
The player/artifical intelligence should only be able to control the car with this interface (not moving the body - otherwhise its unrealistic and unfunny... )

device-2014-03-19-141830.png (87.35 KiB) Viewed 2896 times

I know the joystick is hard to handle, but this should not be a game, but only an example :lightning:
Enjoy it, and feel free to use it in your games.

You can find the commit here: ... d0e16513f4
My software never has bugs. It just develops random features.
Posts: 30
Joined: Thu Sep 29, 2011 9:19 pm

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 8 guests