Beispiel #1
0
  void generateBackground(int size) {
    backgroundWidth = 100;
    int spacing = backgroundWidth;
    int id = 0;
    for (int i = 0; i < bounds.getWidth() / spacing; i++) {
      background[id][0] = spacing * (i + 1) - bounds.getWidth() / 2;
      background[id][1] = -bounds.getHeight() / 2;
      background[id][2] = spacing * (i + 1) - bounds.getWidth() / 2;
      background[id][3] = 0;
      background[id][4] = spacing * (i + 1) - bounds.getWidth() / 2;
      background[id][5] = bounds.getHeight();

      background[id][6] = rand.nextInt(3) - 1;
      background[id][7] = rand.nextInt(3) - 1;
      background[id][8] = 1;
      id++;
    }
    for (int i = 0; i < bounds.getHeight() / spacing; i++) {
      background[id][0] = -bounds.getHeight() / 2;
      background[id][1] = spacing * (i + 1) - bounds.getHeight() / 2;
      background[id][2] = 0;
      background[id][3] = spacing * (i + 1) - bounds.getWidth() / 2;
      background[id][4] = bounds.getWidth();
      background[id][5] = spacing * (i + 1) - bounds.getHeight() / 2;

      background[id][6] = rand.nextInt(3) - 1;
      background[id][7] = rand.nextInt(3) - 1;
      background[id][8] = 1;
      id++;
    }
  }
Beispiel #2
0
  void itemHandeler(Graphics2D map) {
    boolean tmp = false;
    if (rand.nextInt((int) (300 * delta + difficulty * 40)) <= 1 && tmp) {
      int x = rand.nextInt(4) - 2;
      int y = rand.nextInt(4) - 2;
      int type = 1;
      if (x == 0 && y == 0) {
        x = 0;
        y = 1;
      }
      if (rand.nextInt(10) == 1) {
        type = 2;
      }
      if (rand.nextInt(5) == 1)
        for (int i = 0; i < player.weapon.length; i++)
          if (player.weapon[i][11] != null && (Boolean) player.weapon[i][11] == true)
            if ((Integer) player.weapon[i][10] < 5) type = 3;

      spawnItem(player.body.getCenterX() + 200 * x, player.body.getCenterY() + 200 * y, type);
    }

    for (int i = 1; i < items.length; i++) {
      if (items[i] != null) {
        if (items[i].body == null) {
          items[i] = null;
        } else {
          items[i].Runtime(map, player, delta);
        }
      }
    }
  }
Beispiel #3
0
  void enemieHandeler() {
    int ran = (int) ((70 - difficulty) * delta);
    if (ran <= 0) return;
    if (rand.nextInt(ran) == 1) {
      int x = rand.nextInt(2);
      int y = rand.nextInt(2);
      int size = rand.nextInt(1000) + 50;
      if (x == 0 && y == 0)
        if (rand.nextBoolean()) x = rand.nextInt(4) + 1;
        else y = rand.nextInt(4) + 1;

      if (rand.nextBoolean()) x = -x;
      if (rand.nextBoolean()) y = -y;
      size = size * (rand.nextInt(difficulty) + 1);

      x = (int) (x * 400 + player.body.getCenterX());
      y = (int) (y * 400 + player.body.getCenterY());

      int type = 0;

      if (rand.nextInt(60 / difficulty) <= 1) type = rand.nextInt(3) + 1;

      spawnEnemie(x, y, size, type);
    }
  }
Beispiel #4
0
 void characterHandeler(Graphics2D map) {
   for (int i = 0; i < characterExplosions.length; i++) {
     if (characterExplosions[i] != null) {
       if (characterExplosions[i].render(map)) characterExplosions[i] = null;
     }
   }
   for (int i = 0; i < characters.length; i++) {
     if (characters[i] != null) {
       if (characters[i].isDead == true) {
         newCExplosion(characters[i].body.getCenterX(), characters[i].body.getCenterY());
         if (rand.nextInt(5) == 1) {
           int type = 1;
           if (rand.nextInt(10) == 1) {
             type = 2;
           }
           if (rand.nextInt(4) == 1)
             for (int j = 0; j < player.weapon.length; j++)
               if (player.weapon[j][11] != null && (Boolean) player.weapon[j][11] == true)
                 if ((Integer) player.weapon[j][10] < 5) type = 3;
           spawnItem(characters[i].body.getCenterX(), characters[i].body.getCenterY(), type);
         }
         characters[i] = null;
       } else {
         if (characters[i].id != "player") {
           characters[i].Folow(player);
           double[] pos = checkIfInsideBounds(characters[i]);
           characters[i].body.setFrame(
               pos[0], pos[1], characters[i].body.getWidth(), characters[i].body.getHeight());
           characters[i].Update(xOffset, yOffset, delta);
         }
         characters[i].Render(map, characters);
         if (Math.pow(characters[i].body.getCenterX() - characters[i].body.getCenterX(), 2)
                 + Math.pow(player.body.getCenterY() - player.body.getCenterY(), 2)
             < Math.pow(width * 1.5, 2)) {
           map.setColor(Color.darkGray);
           map.draw(characters[i].body);
         }
       }
     }
   }
 }
  // private void colorSCC (ArrayList<Position> vertexSet, Color color)
  private void colorSCC() {
    /*

    for (Position p:vertexSet)
    {
    	setVertexColor (p, color);

    }*/

    java.util.List<Set<Position>> sccs =
        new ConnectivityInspector<Position, DefaultEdge>(graph).connectedSets();
    for (Set<Position> s : sccs) {
      Color color = new Color(randGen.nextInt());
      for (Position p : s) {
        setVertexColor(p, color);
      }
    }
  }
Beispiel #6
0
  void renderBackground(Graphics2D g2d) {
    g2d.setColor(new Color(0, 0, 0, 30));
    for (int i = 0; i < background.length; i++) {
      if (background[i][8] == 1) {
        if (Math.round(rand.nextInt(200) * delta) == 1) background[i][6] = (rand.nextInt(3) - 1);
        if (Math.round(rand.nextInt(200) * delta) == 1) background[i][7] = (rand.nextInt(3) - 1);

        if (background[i][6] < 0) background[i][6] = background[i][6] - 0.01;
        else if (background[i][6] > 0) background[i][6] = background[i][6] + 0.01;

        if (background[i][7] < 0) background[i][7] = background[i][7] - 0.01;
        else if (background[i][7] > 0) background[i][7] = background[i][7] + 0.01;

        if (background[i][2] < background[i][0] - backgroundWidth * 3)
          background[i][6] = rand.nextInt(2);
        if (background[i][2] > background[i][0] + backgroundWidth * 3)
          background[i][6] = -rand.nextInt(2);

        if (background[i][3] < background[i][1] - backgroundWidth * 3)
          background[i][7] = rand.nextInt(2);
        if (background[i][3] > background[i][1] + backgroundWidth * 3)
          background[i][7] = -rand.nextInt(2);

        background[i][2] = background[i][2] + background[i][6] / delta / 10;
        background[i][3] = background[i][3] + background[i][7] / delta / 10;

        Path2D tmp = new Path2D.Double();
        tmp.moveTo(background[i][0], background[i][1]);
        tmp.curveTo(
            background[i][0],
            background[i][1],
            background[i][2],
            background[i][3],
            background[i][4],
            background[i][5]);
        g2d.draw(tmp);
      }
    }
  }