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:
https://www.iforce2d.net/b2dtut/top-down-car
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
  1.  
  2. MassData data = mCarBody.getMassData();
  3.  data.mass = 3.9f;
  4.  mCarBody.setMassData(data);
  5.  
Parsed in 0.010 seconds, using GeSHi 1.0.8.4

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... )

Preview:
device-2014-03-19-141830.png
device-2014-03-19-141830.png (87.35 KiB) Viewed 2538 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:
https://github.com/myfknoll/AndEngineEx ... d0e16513f4
My software never has bugs. It just develops random features.

https://market.android.com/developer?pub=myfknoll
myfknoll
 
Posts: 30
Joined: Thu Sep 29, 2011 9:19 pm

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests