From 2f699eb5e5516c748d002b7e4a529e995602a0f8 Mon Sep 17 00:00:00 2001 From: David96 Date: Sat, 2 Jan 2021 12:13:31 +0100 Subject: [PATCH] Properly reset world speed --- World.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/World.java b/World.java index 31382b6..4c7411c 100644 --- a/World.java +++ b/World.java @@ -4,9 +4,11 @@ import java.util.Random; class World implements Drawable { private static final int DISTANCE = 250; + private static final int START_SPEED = 150; + private static final int ACCELERATION = 2; + private final ArrayList _obstacles; - private double _speed = 150; - private double _acc = 2; + private double _speed; private final Random _random; public World(GameScreen game) @@ -21,6 +23,7 @@ class World implements Drawable { _obstacles.clear(); createObstacle(TurtleWelt.WIDTH); + _speed = START_SPEED; } private void createObstacle(int x) @@ -58,7 +61,7 @@ class World implements Drawable } // Increase speed according to acceleration - _speed += _acc * elapsed * 1e-3; + _speed += ACCELERATION * elapsed * 1e-3; } public boolean checkCollision(Rectangle r)