From 22bcc0d7440abc93ca03871086e95ebaad606166 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 16 Jan 2009 13:44:15 +0100 Subject: [PATCH] Adjusted ball spawning mechanics. --- src/net/habraun/kong/Ball.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/net/habraun/kong/Ball.scala b/src/net/habraun/kong/Ball.scala index 7c71674..f40e7f4 100644 --- a/src/net/habraun/kong/Ball.scala +++ b/src/net/habraun/kong/Ball.scala @@ -35,17 +35,18 @@ class Ball(startingX: Int, startingY: Int) { body.setFriction(0) body.setRestitution(1) body.setRotatable(false) + body.setMaxVelocity(400, 400) def init { val mod = (r: Random) => (r.nextInt(2) + 1) * 2 - 3 // result: -1 or +1 - val vel = (r: Random, factor: Double) => r.nextInt(101) + 100 // result: 100-200 * factor + val vel = (r: Random, min: Int, factor: Float) => (r.nextInt(101) + min) * factor val xMod = mod(r) val yMod = mod(r) - val xVel = xMod * vel(r, 1.5) - val yVel = yMod * vel(r, 1) + val xVel = xMod * vel(r, 100, 3) + val yVel = yMod * vel(r, 0, 2) body.adjustVelocity(new Vector2f(body.getVelocity).negate) body.adjustVelocity(new Vector2f(xVel, yVel)) -- 2.11.4.GIT