Properly reset world speed
This commit is contained in:
parent
c90e51dffa
commit
2f699eb5e5
|
|
@ -4,9 +4,11 @@ import java.util.Random;
|
||||||
class World implements Drawable
|
class World implements Drawable
|
||||||
{
|
{
|
||||||
private static final int DISTANCE = 250;
|
private static final int DISTANCE = 250;
|
||||||
|
private static final int START_SPEED = 150;
|
||||||
|
private static final int ACCELERATION = 2;
|
||||||
|
|
||||||
private final ArrayList<Rectangle> _obstacles;
|
private final ArrayList<Rectangle> _obstacles;
|
||||||
private double _speed = 150;
|
private double _speed;
|
||||||
private double _acc = 2;
|
|
||||||
private final Random _random;
|
private final Random _random;
|
||||||
|
|
||||||
public World(GameScreen game)
|
public World(GameScreen game)
|
||||||
|
|
@ -21,6 +23,7 @@ class World implements Drawable
|
||||||
{
|
{
|
||||||
_obstacles.clear();
|
_obstacles.clear();
|
||||||
createObstacle(TurtleWelt.WIDTH);
|
createObstacle(TurtleWelt.WIDTH);
|
||||||
|
_speed = START_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createObstacle(int x)
|
private void createObstacle(int x)
|
||||||
|
|
@ -58,7 +61,7 @@ class World implements Drawable
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increase speed according to acceleration
|
// Increase speed according to acceleration
|
||||||
_speed += _acc * elapsed * 1e-3;
|
_speed += ACCELERATION * elapsed * 1e-3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkCollision(Rectangle r)
|
public boolean checkCollision(Rectangle r)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user