Beispiel #1
0
 public void handleInput() {
   InputHandler input = Game.getInstance().getInputHandler();
   if (input.isSpacePressed()) {
     // If previous state complete
     if (state.isComplete()) {
       // Jump again
       state = new PlayerJumping(this);
     }
   }
   // if not running and previous state complete, run again
   else if (!(state instanceof PlayerRunning) && state.isComplete())
     state = new PlayerRunning(this);
 }
Beispiel #2
0
  @Override
  public void draw(Graphics2D g) {
    // Draw small black rectangle to merge
    // road and dino tail
    g.setColor(GameConfig.COLOR_BACKGROUND);
    g.fillRect(x + 6, y + 28, 20, 10);

    state.draw(g);
  }
Beispiel #3
0
 @Override
 public void update(long elapsedTime) {
   handleInput();
   state.update(elapsedTime);
 }