Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am making a breakout game in Android using the LibGDX version of Box2D. I have a ball that I am applying a force to with the following code...

getBody().applyForceToCenter(-10000000000.0f, -10000000000.0f);

This makes the ball move properly, but it never seems to gain a lot of speed (and I want to make it go super fast). I tried adding an accelerate method where I applied the force 40 times, but again it doesn't seem to move that fast. What is a good way to make a Body go "Super fast" in Box2D?

If there is acceleration I would like it to be as short as possible.

I tried adding the following....

World.setVelocityThreshold(1000000.0f);

But now the ball doesn't seem to "bounce" off walls, do I need to raise my restitution or something?

share|improve this question
    
there is an speed limit somewhere in the box2d configurations which you might alter. But in their manual, they indicated that max speed should not be very large. check this question –  Ali.S Jan 23 '13 at 16:54
    
Any idea where the maxTranslation is in LibGDX? –  Jackie Jan 23 '13 at 16:58
    
I've got no idea even what libGDX is but a google search pointed me towards this –  Ali.S Jan 23 '13 at 17:03
    
Nice thats exactly what I was looking for let me check it out (BTW LibGDX is a game engine for android that comes with a jni "wrapped" version of Box2D –  Jackie Jan 23 '13 at 17:05
1  
Box2D is designed for static scenes (as in nothing removed or created, movement is fine) and realistic simulations. Using it for something like breakout may very well be more complicated than creating your own very simple physics engine. –  ClassicThunder Jan 23 '13 at 18:16

1 Answer 1

up vote 3 down vote accepted

Tried also to create a breakout clone, but stopped for now, for some other reasons... anyway this is what I learned so far, during development.

  1. Use Meters instead of Pixels, Box2D uses MKS (meters, kilograms, and seconds) so when you have a Viewport of e.g. 1280x720 , this would be a length 1,28km. Then your Ball must have an outrageous speed to be "fast" in this long distance. Better use meters e.g. 50x20 (or something like that) => http://box2d.org/2011/12/pixels/
  2. If you don't use Meters, but a higher BOX_STEP (e.g. 1/500f) and more BOX_VELOCITY_ITERATIONS during each render()-call, then you can speed up on a Desktop, but on Android it just gets down to 3FPS which isn't really "fast".
  3. "Fix your timestep" => http://gafferongames.com/game-physics/fix-your-timestep/ (for this there are some other Stackoverflow Entries, which currently couldn't find)

The TL;DR-Version: Use Meters instead Pixels, then you don't have to use such an high force / velocity, and it will be fast on android and desktop.

Best Regards and hoping this helped a bit

share|improve this answer
    
Thanks I will try these and give you the check in a bit! –  Jackie Jan 24 '13 at 15:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.