Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create a game like Doodle Jump. I'm using libgdx and Box2d. I needadvice on how to make my ball bounce constantly and with the same height.

I've tried setting the ball's body restitution to 1 so it can jump constantly, but when I jump on a block the "impulse" is smaller. I also tried to detect the collision, then apply an impulse but it didn't work either.

How can I make the ball bounce to the same height every time?

share|improve this question
You may want to consider rolling out your own "physics" instead of using box2d. A game like doodle jump wouldn't require too much work to accomplish without a physics engine. – Jon Feb 28 '13 at 17:57
up vote 15 down vote accepted

enter image description here

When the ball (red trajectory curve) hits a block higher up (blue rectangle), it will be moving slower than when it hit a block lower down (green rectangle). Hence why it doesn't bounce any higher than where it came from.

Physically, this makes sense.

Doodle Jump obviously isn't physically accurate. If you want an effect like in Doodle Jump where the impulse from a collision is always the same, you should set the vertical velocity to some value yourself whenever collisions happen, with ball.speed.y = 7; or similar.

share|improve this answer
Thanks! I'll try it ;) – Ion Farima Feb 28 '13 at 20:36

Box2D worlds use damping and friction, consider that the world may be applying a damping to your objects as they are simulated.

share|improve this answer

I'd also like to throw in to the mix that it may not be necessary to use a physics engine for this. Depending on how your game collisions are handled (specifically, the collision response) you may find you can create a very simply bounding box system over which you have complete control. In fact, in "doodle jump" style games it's even easier. Rather than worrying about detecting collisions in box2d and working out whether the collision should be disabled or not (e.g. you hit a platform from underneath), the doodle jump scenario actually a lot simpler. If your ball is travelling "down" (y is decreasing) and it passes the y value of a platform, and it's within the left/right bounds of a platform, then it collides. The only really "complex" thing is the parabolic flight path you'd take after, but that's just a tiny bit of math (

Collisions with other items in the world that don't require a response (e.g. hitting a bonus) can be easily solved with just bounding boxes.

Box2D is phenomenal, but often overkill if you have simple requirements.. IMO.

share|improve this answer

Remember (float value = velocity.y) velocity of the ball before it collides with platform, and set after bounce: ball.velocity.y = value * (-1)

Maybe you will be interesting to look in this posts:
first post
second post

P.S. I can't submit code here, please look in "first post" in last comment. There is code how I resolved similar issue.

share|improve this answer

Your Answer


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.