private void spawnRandomers() { for (int i = 0; i < randomN; i++) { float x = (float) Math.random() * width; float y = (float) Math.random() * height; float r = (float) Math.sqrt( Math.pow(((Player) players.get(0)).getX() - x, 2) + Math.pow(((Player) players.get(0)).getY() - x, 2)); while (r < distanceLimit) { x = (float) Math.random() * width; y = (float) Math.random() * height; r = (float) Math.sqrt( Math.pow(((Player) players.get(0)).getX() - x, 2) + Math.pow(((Player) players.get(0)).getY() - y, 2)); } enemies.add(new EnemyTypes.Random(x, y, 0.5f, borders)); } spawnRandomersB = false; }
private void spawnCircles() { if (circular) { for (int i = 0; i < ballN; i++) { double degree = Math.random() * 2 * Math.PI; float x = ((Player) players.get(0)).getX() + distance * (float) Math.sin(degree * i); float y = ((Player) players.get(0)).getY() + distance * (float) Math.cos(degree * i); enemies.add(new EnemyTypes.Circle(x, y, invSpeed)); } } else { for (int i = 1; i < (ballN / 2); i++) { float x = (i * 2 * width) / (ballN); float y = 0; enemies.add(new EnemyTypes.Circle(x, y, invSpeed)); } for (int i = (ballN / 2) + 1; i < ballN; i++) { float x = ((i - ballN / 2) * 2 * width) / ballN; float y = height; enemies.add(new EnemyTypes.Circle(x, y, invSpeed)); } } spawnIncrease = false; }