Exemplo n.º 1
0
  /**
   * Base tick method for the level. Updates all entities, tiles, and player. Has slow repopulation
   * algorithm
   */
  public void tick() {
    player.tick();
    List<Entity> toTick = new ArrayList<Entity>();
    int lr = 7;
    for (int x = -lr; x < lr; x++) {
      for (int y = -lr; y < lr; y++) {
        Tile tile = getTile(player.x + x, player.z + y);
        tile.addToTick(toTick);
        tile.tick();
      }
    }

    for (int i = 0; i < toTick.size(); i++) {
      Entity e = toTick.get(i);
      e.tick(this);
    }
    tickcount++;
    if (tickcount % 1800 == 0) {
      System.out.println("Adding entity to world");
      if (r != null) {
        int rx = r.nextInt(w);
        int ry = r.nextInt(h);

        if (skillNoise.noise(rx / 80d, ry / 80d) > 0.0) {
          SmallMob mob = new SmallMob();
          if (!tiles[rx + ry * w].blocks(mob)) {
            tiles[rx + ry * w].addEntity(r.nextInt(4), mob);
          }
        }
      }
    }
  }
Exemplo n.º 2
0
  public void tick() {
    super.tick();

    // Generate smoke for buildings.
    if (buildTimer == totalBuildTime && !type.equals("Basic Hut")) {
      this.addSmoke();
    }

    if (totalBuildTime > buildTimer && startedBuilding) {
      if (buildTimer % (totalBuildTime / 6) == 0 && buildTimer != 0) animFrame++;
      buildTimer++;
    }
  }
Exemplo n.º 3
0
  private void update() {

    for (Entity e : entities) {
      e.tick();
    }
  }
Exemplo n.º 4
0
 public void tick() {
   super.tick();
   Game.window().setTitle("X: " + abspx_xPos + "Y: " + abspx_yPos);
 }