Exemplo n.º 1
0
  private void updateRunning(List<TouchEvent> touchEvents, float deltaTime) {

    timePassed += deltaTime;

    for (TouchEvent event : touchEvents) {
      if (event.type == TouchEvent.TOUCH_DOWN) {

        if (event.x < buttonWidth) {
          player.moveLeft();
        } else if (event.x > buttonWidth + game.getGraphics().getHeight()) {
          player.moveRight();
        }
      }
    }

    if (!player.isAlive) {
      connection.write("LOST".getBytes());
      opponent.scored();
      if (opponent.getScore() == goal) {
        ((TronGame) game).saveLose();
        state = GameState.Loser;
      } else {
        countdown = 300.0f;
        state = GameState.Lose;
      }
    } else if (timePassed > 10.0) {
      player.update();
      grid.update(player);
      timePassed -= 10.0f;
    }
  }
Exemplo n.º 2
0
 @Override
 public void simpleUpdate(float tpf) {
   if ((Boolean) player.getUserData("alive")) {
     spawnEnemies();
     spawnBlackHoles();
     handleCollisions();
     handleGravity(tpf);
   } else if (System.currentTimeMillis() - (Long) player.getUserData("dieTime") > 4000f
       && !gameOver) {
     // spawn player
     player.setLocalTranslation(500, 500, 0);
     guiNode.attachChild(player);
     player.setUserData("alive", true);
     sound.spawn();
     grid.applyDirectedForce(new Vector3f(0, 0, 5000), player.getLocalTranslation(), 100);
   }
   grid.update(tpf);
   hud.update();
 }
  /** Method declaration */
  void updateResult() {

    if (iResult == 0) {

      // in case 'help' has removed the grid
      if (bHelp) {
        pResult.removeAll();
        pResult.add("Center", gResult);
        pResult.doLayout();

        bHelp = false;
      }

      gResult.update();
      gResult.repaint();
    } else {
      showResultInText();
    }

    txtCommand.selectAll();
    txtCommand.requestFocus();
  }