@Override public Sprite getSprite() { Log.v("Program State", "Player.getSprite"); return currentAnimation.getCurrentSprite(); }
@Override public void update(GameTime gameTime, InputChange inputChange, GameState gameState) { super.update(gameTime, inputChange, gameState); Log.v("Program State", "Player.update"); KeyState currentKeyState = inputChange.getCurrentState().getKeyState(); float elapsedSeconds = gameTime.getElapsedTime().getSeconds(); /* * Handles player state given user input through character keys */ if (!charging && inputChange.justPressed(ButtonManager.get(Action.Charge))) { charging = true; chargeStartTime = gameTime.getCurrentTime(); updatePlayerVelocity(); } if (charging && CHARGE_DURATION < gameTime.getTimeFrom(chargeStartTime).getSeconds()) { charging = false; updatePlayerVelocity(); } if (charging) { currentAnimation.moveForward(elapsedSeconds * (getPlayerSpeedScaleFactor() - 1)); } /* * Handles player's left and right movement given user input through arrow keys */ if (!currentKeyState.anyPressed( ButtonManager.get(Action.MoveLeft), ButtonManager.get(Action.MoveRight)) || currentKeyState.allPressed( ButtonManager.get(Action.MoveLeft), ButtonManager.get(Action.MoveRight))) { charging = false; boolean hadFlipped = currentAnimation.getFlip(); setAnimation("idle"); currentAnimation.setFlip(hadFlipped); myVelocity.setX(0); } else if (inputChange.justPressed(ButtonManager.get(Action.MoveRight)) || (inputChange.justReleased(ButtonManager.get(Action.MoveLeft)) && currentKeyState.isDown(ButtonManager.get(Action.MoveRight)))) { setAnimation("run"); movingRight = true; currentAnimation.setFlip(movingRight); updatePlayerVelocity(); } else if (inputChange.justPressed(ButtonManager.get(Action.MoveLeft)) || (inputChange.justReleased(ButtonManager.get(Action.MoveRight)) && currentKeyState.isDown(ButtonManager.get(Action.MoveLeft)))) { setAnimation("run"); movingRight = false; currentAnimation.setFlip(movingRight); updatePlayerVelocity(); } /* * Handles player's jumping capabilities */ if (jumping) { float jumpSeconds = gameTime.getTimeFrom(jumpStartTime).getSeconds(); /* if ( jumpSeconds < MAX_HOLD_TIME && inputChange.isHeldDown ( ButtonManager.get ( Action.Jump ) ) ) { } else { jumpForce.turnOff(); } */ jumping = false; /* if ( Math.abs(myVelocity.getY()) < application.Constants.EPSILON ) { jumping = false; } */ } else if (!jumping && inputChange.justPressed(ButtonManager.get(Action.Jump))) { jumping = true; jumpStartTime = gameTime.getCurrentTime(); } }
@Override public void update(GameTime gameTime, InputChange inputChange, GameState gameState) { Position playerPosition = gameState.getPlayer().getPosition(); Log.v("Camera Position", playerPosition); }