diff --git a/World.java b/World.java index 2318bec..b5d3f1a 100644 --- a/World.java +++ b/World.java @@ -6,6 +6,7 @@ class World implements Drawable private static final int DISTANCE = 250; private static final int START_SPEED = 150; private static final int ACCELERATION = 2; + private static final int GAP_SIZE = 100; private final ArrayList _obstacles; private String _obstacleColor; @@ -42,9 +43,10 @@ class World implements Drawable 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, 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)