Examples of Powerup


Examples of org.sfsoft.jfighter2dx.powerups.Powerup

   * Actualiza el estado de los powerups en pantalla
   * @param dt
   */
  private void updatePowerups(float dt) {
   
    Powerup item = null;
   
    for (int i = powerups.size - 1; i >= 0; i--) {
      item = powerups.get(i);
      item.update(dt);
     
      if (item.getX() < 0)
        powerups.removeIndex(i);
    }
  }
View Full Code Here

Examples of org.sfsoft.jfighter2dx.powerups.Powerup

   */
  private void checkCollisions(float dt) {
   
    Bullet bullet = null;
    Enemy enemy = null;
    Powerup powerup = null;
    List<Bullet> bullets = ship.getBullets();
   
    // Comprueba si los proyectiles del personaje han alcanzado a algún enemigo
    for (int i = enemies.size - 1; i >= 0; i--) {
      enemy = enemies.get(i);
      for (int j = bullets.size() - 1; j >= 0; j--) {
        bullet = bullets.get(j);
       
        if (bullet.getRect().overlaps(enemy.getRect())) {
         
          // Si el enemigo no es meteorito ni bala enemiga se explosiona y se elimina
          if ((!enemy.getClass().getSimpleName().equals("Stone")) && (!enemy.getClass().getSimpleName().equals("ShooterBullet"))) {
           
            enemy.hit();
            if (enemy.getLives() == 0) {
              ship.addScore(enemy.getValue());
             
              Explosion explosion = new Explosion(enemy.getX() - Constants.ENEMY_WIDTH, enemy.getY());
              explosions.add(explosion);
              enemies.removeIndex(i);
             
              if (game.configurationManager.isSoundEnabled())
                ResourceManager.getSound("explosion").play();
            }
           
          }
          // Si se dispara contra la bala de un enemigo, el proyectil no desaparece
          // Si se dispara un misil, éste tampoco desaparece hasta que no llega al final de la pantalla,
          // aunque haya acertado a algún enemigo
          if ((!enemy.getClass().getSimpleName().equals("ShooterBullet")) &&
              (!bullet.getClass().getSimpleName().equals("Missile")))
            bullets.remove(j);
        }
      }
    }
   
    // Comprueba si la nave colisiona con algún enemigo
    if (ship.getShieldTime() <= 0) {
      for (int i = enemies.size - 1; i >= 0; i--) {
        enemy = enemies.get(i);
       
        if (enemy.getRect().overlaps(ship.getRect())) {
         
          enemy.hit();
          if (enemy.getLives() == 0) {
            ship.addScore(enemy.getValue());
           
            Explosion explosion = new Explosion(enemy.getX(), enemy.getY());
            explosions.add(explosion);
            enemies.removeIndex(i);
           
            if (game.configurationManager.isSoundEnabled())
              ResourceManager.getSound("explosion").play();
          }
         
          if (enemy.getClass().getSimpleName().equals("Stone")) {
            // El usuario muere al chocar con una roca
            game.score = ship.getScore();
            game.setScreen(new GameOverScreen(game));
          }
         
          ship.hit();
          if (game.configurationManager.isSoundEnabled())
            ResourceManager.getSound("buzz").play();
         
          if (ship.getLives() == 0) {
            // El usuario muere al quedarse sin vidas
            game.score = ship.getScore();
            game.setScreen(new GameOverScreen(game));
          }
        }
      }
    }
   
    // Comprueba si el personaje ha cogido algún item
    for (int i = powerups.size - 1; i >= 0; i--) {
      powerup = powerups.get(i);
     
      if (powerup.getRect().overlaps(ship.getRect())) {
       
        if (game.configurationManager.isSoundEnabled())
          ResourceManager.getSound("item").play();
       
        if (powerup.getClass().getSimpleName().equals("Bomb"))
          ship.setBombs(ship.getBombs() + 1);
       
        if (powerup.getClass().getSimpleName().equals("Shield"))
          ship.setShieldTime(ship.getShieldTime() + Constants.SHIELD_TIME);
       
        powerups.removeIndex(i);
      }
    }
View Full Code Here

Examples of org.sfsoft.jfighter2dx.powerups.Powerup

    // Genera powerups aleatoriamente
    if (powerupTime >= POWERUP_TIME) {
     
      int i = generator.nextInt(PowerupType.values().length);
     
      Powerup powerup = PowerupSpawner.createPowerup(PowerupType.values()[i]);
      spriteManager.getPowerups().add(powerup);
      powerupTime = 0;
    }
}
View Full Code Here

Examples of org.sfsoft.jfighter2dx.powerups.Powerup

    
    if (powerupTime >= POWERUP_TIME) {
     
      int i = generator.nextInt(PowerupType.values().length);
     
      Powerup powerup = PowerupSpawner.createPowerup(PowerupType.values()[i]);
      spriteManager.getPowerups().add(powerup);
      powerupTime = 0;
   
  }
View Full Code Here

Examples of org.sfsoft.jfighter2dx.powerups.Powerup

*/
public class PowerupSpawner {

  public static Powerup createPowerup(PowerupType type) {
   
    Powerup powerup = null;
   
    switch (type) {
      case BOMB:
        powerup = new Bomb(1000, new Random().nextInt(SCREEN_HEIGHT - ITEM_HEIGHT), -100f);
        break;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.