pl/mbogusz3/invaders/model/InvadersModel.java
/**
	 * Recalculate player actions (movement and shooting). Called from recalculate().
	 * @param frameTime frame time, in seconds.
	 */
Recalculate player actions (movement and shooting). Called from recalculate().
@param frameTime frame time, in seconds.
Recalculate player actions ( movement and shooting ) . Called from recalculate () . @param frameTime frame time in seconds .
private void recalculatePlayerActions(double frameTime) {
		boolean leftKeyDown = this.getKeyState(KeyEvent.VK_LEFT);
		boolean rightKeyDown = this.getKeyState(KeyEvent.VK_RIGHT);
		if(leftKeyDown && !rightKeyDown) {
			this.player.move(-1, frameTime);
			this.hasChanged = true;
		} else if(!leftKeyDown && rightKeyDown) {
			this.player.move(1, frameTime);
			this.hasChanged = true;
		}
		boolean spaceKeyDown = this.getKeyState(KeyEvent.VK_SPACE);
		if(this.playerProjectile == null && spaceKeyDown) {
			this.playerProjectile = new Projectile(this.player.getPosition(), 0.9);
			this.hasChanged = true;
		}
		if(this.playerProjectile != null) {
			this.playerProjectile.move(frameTime);
			if(this.playerProjectile.isInvalid()) {
				this.playerProjectile = null;
			}
			this.hasChanged = true;
		}
	}
private void recalculatePlayerActions ( double frameTime ) { boolean leftKeyDown = this . getKeyState ( KeyEvent . VK_LEFT ) ; boolean rightKeyDown = this . getKeyState ( KeyEvent . VK_RIGHT ) ; if ( leftKeyDown && ! rightKeyDown ) { this . player . move ( - 1 , frameTime ) ; this . hasChanged = true ; } else if ( ! leftKeyDown && rightKeyDown ) { this . player . move ( 1 , frameTime ) ; this . hasChanged = true ; } boolean spaceKeyDown = this . getKeyState ( KeyEvent . VK_SPACE ) ; if ( this . playerProjectile == null && spaceKeyDown ) { this . playerProjectile = new Projectile ( this . player . getPosition ( ) , 0.9 ) ; this . hasChanged = true ; } if ( this . playerProjectile != null ) { this . playerProjectile . move ( frameTime ) ; if ( this . playerProjectile . isInvalid ( ) ) { this . playerProjectile = null ; } this . hasChanged = true ; } }
Recalculate player actions (movement and shooting).
Recalculate player actions ( movement and shooting ) .
// Player movement // Player shooting