Make modifying GAP_SIZE easy
This commit is contained in:
+4
-2
@@ -6,6 +6,7 @@ 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 START_SPEED = 150;
|
||||||
private static final int ACCELERATION = 2;
|
private static final int ACCELERATION = 2;
|
||||||
|
private static final int GAP_SIZE = 100;
|
||||||
|
|
||||||
private final ArrayList<Rectangle> _obstacles;
|
private final ArrayList<Rectangle> _obstacles;
|
||||||
private String _obstacleColor;
|
private String _obstacleColor;
|
||||||
@@ -42,9 +43,10 @@ class World implements Drawable
|
|||||||
|
|
||||||
private void createObstacle(int x)
|
private void createObstacle(int x)
|
||||||
{
|
{
|
||||||
int gap = _random.nextInt(TurtleWelt.HEIGHT - 200) + 50;
|
// Position gap somewhere between 50px and HEIGHT - 50px
|
||||||
|
int gap = _random.nextInt(TurtleWelt.HEIGHT - GAP_SIZE - 100) + 50;
|
||||||
_obstacles.add(new Rectangle(x, 0, 30, gap, _obstacleColor, false));
|
_obstacles.add(new Rectangle(x, 0, 30, gap, _obstacleColor, false));
|
||||||
_obstacles.add(new Rectangle(x, gap + 100, 30, TurtleWelt.HEIGHT, _obstacleColor, false));
|
_obstacles.add(new Rectangle(x, gap + GAP_SIZE, 30, TurtleWelt.HEIGHT, _obstacleColor, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(double elapsed)
|
public void update(double elapsed)
|
||||||
|
|||||||
Reference in New Issue
Block a user