Esempio n. 1
0
 @Override
 public void keyPressed(int k) {
   if (k == KeyEvent.VK_SPACE) {
     if (textEventListener.isPlaying()) {
       textEventListener.keyPressed(k);
     } else if (fire.intersects(
         new Rectangle(player.getX(), player.getY(), player.getWidth(), player.getHeight()))) {
       gsm.setState(GameStateManager.FIRESTATE);
     } else if (earth.intersects(
         new Rectangle(player.getX(), player.getY(), player.getWidth(), player.getHeight()))) {
       gsm.setState(GameStateManager.EARTHSTATE);
     } else if (water.intersects(
         new Rectangle(player.getX(), player.getY(), player.getWidth(), player.getHeight()))) {
       gsm.setState(GameStateManager.WATERSTATE);
     } else if (air.intersects(
         new Rectangle(player.getX(), player.getY(), player.getWidth(), player.getHeight()))) {
       gsm.setState(GameStateManager.AIRSTATE);
     }
   }
   if (paused) {
     pauseMenu.keyPressed(k);
   }
   if (k == KeyEvent.VK_ESCAPE) {
     pauseMenu.init();
     paused = !paused;
   }
   player.keyPressed(k);
 }
Esempio n. 2
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);
   }
 }