Esempio n. 1
0
  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;
  }
Esempio n. 2
0
 private void spawnBomb() {
   float x, y;
   for (int i = 0; i < bombN; i++) {
     if (Math.random() > .5) { // top/bottom
       y = (Math.random() > .5) ? borders[1] : borders[3];
       x = (float) Math.random() * borders[2] - borders[0]; // width
     } else {
       x = (Math.random() > .5) ? borders[0] : borders[2];
       y = (float) Math.random() * borders[3] - borders[1]; // height
     }
     enemies.add(new EnemyTypes.Bomb(x, y, 1f, borders, scbInstance));
   }
 }
Esempio n. 3
0
  private void levelSetup() {
    reset();

    switch (level) {
      case 1:
        distance = 600;
        monsterN = 0;
        randomN = 0;
        rainN = 30;
        defaultDistance = 600;
        timeLast = 10000;
        spawnCircleB = true;
        break;
      case 2:
        distance = 600;
        monsterN = 0;
        randomN = 30;
        rainN = 30;
        defaultDistance = 600;
        timeLast += 10000;
        spawnCircleB = true;
        break;
      case 3:
        distance = 600;
        monsterN = 30;
        randomN = 0;
        rainN = 0;
        defaultDistance = 600;
        timeLast += 10000;
        spawnCircleB = true;
        break;
      default:
        distance = (float) (Math.random() * 200 + 400 - level * 5);
        monsterN = (int) (Math.random() * 25 + 10 + level);
        randomN = (int) (Math.random() * 25 + 10 + level);
        rainN = (int) (Math.random() * 10 + 10 + level);
        defaultDistance = distance;
        timeLast += 5000 + level * 1000;
        spawnCircleB = true;
    }

    monsterN *= monsterMultiplier;
    randomN *= monsterMultiplier;
    spawnMonsterB = true;
    spawnRandomersB = true;
    spawnIncrease = true;
    spawnRainB = true;
  }
Esempio n. 4
0
  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;
  }