diff --git a/core/src/com/me/brickbuster/entity/Ball.java b/core/src/com/me/brickbuster/entity/Ball.java index 5a51294..4a89b6a 100644 --- a/core/src/com/me/brickbuster/entity/Ball.java +++ b/core/src/com/me/brickbuster/entity/Ball.java @@ -21,6 +21,7 @@ public class Ball extends Entity implements PhysicsBody, CollisionListener { public static final int BLOCKS_FOR_BOOST = 39; public static final float MINIMUM_ANGLE = MathUtils.PI/16; + public static final float CORRECTION_IMPULSE = 3f; private float speed; private boolean isStuck = true; @@ -64,12 +65,13 @@ public class Ball extends Entity implements PhysicsBody, CollisionListener { } Vector2 velocity = body.getLinearVelocity(); + body.setLinearVelocity(velocity.nor().scl(speed)); + float rad = velocity.angleRad(); if (Math.abs(rad) < MINIMUM_ANGLE || Math.abs(rad) > MathUtils.PI - MINIMUM_ANGLE) { - body.applyLinearImpulse(new Vector2(0, rad > 0? 1 : -1), pos, true); + Vector2 impulse = new Vector2(0, rad > 0? CORRECTION_IMPULSE : -CORRECTION_IMPULSE); + body.applyLinearImpulse(impulse, pos, true); } - - body.setLinearVelocity(velocity.nor().scl(speed)); } @Override