Esempio n. 1
0
 @Override
 public void update() {
   if (textEventListener != null) {
     if (!textEventListener.isPlaying()) {
       textEventListener.playMessage(
           player.getX() / TileMap.tileSize, player.getY() / TileMap.tileSize);
     } else {
       textEventListener.update();
     }
   }
   if (tileMap != null && player != null && !paused && !textEventListener.isPlaying()) {
     if (!player.isDead()) player.update();
     tileMap.center(player.getX(), player.getY());
     tileMap.update(player);
   }
 }
  public void update() {
    player.update();
    player.checkAttack(enemies);

    finish.update();
    finish.checkGrab(player);

    System.out.println(player.getx());
    System.out.println(player.gety());

    bg.setPosition(tileMap.getx(), tileMap.gety());

    tileMap.setPosition(GamePanel.WIDTH / 2 - player.getx(), GamePanel.HEIGHT / 2 - player.gety());

    if (player.isDead()) {
      player.setPosition(130, 2375);
      player.revive();
      player.reset();
      restart();
    }

    //		for(int i = 0; i < drinks.size(); i++){
    //			Alcohol a = drinks.get(i);
    //			a.update();
    //			if(a.shouldRemove()){
    //				drinks.remove(i);
    //				i--;
    //			}
    //		}
    //
    for (int i = 0; i < enemies.size(); i++) {
      Enemy e = enemies.get(i);
      e.update();
      if (player.isDrunk()) {
        e.kill();
      }
      if (e.isDead()) {
        enemies.remove(i);
        e.addScore(Level2State.score);
        i--;
      }
    }

    bg.setPosition(tileMap.getx(), tileMap.gety());
  }