@Override
public void onKeyPress(Key key) {
switch (key) {
case LEFT:
this.isRightPressed = false;
this.isLeftPressed = true;
case RIGHT:
this.isLeftPressed = false;
this.isRightPressed = true;
case UP:
this.isUpPressed = true;
}
}
package com.codegym.games.moonlander;
public class Rocket extends GameObject {
private double speedY, boost;
public Rocket(double x, double y) {
super(x, y, ShapeMatrix.ROCKET);
setSpeedY(0);
setBoost(0.05);
}
public void move() {
this.speedY += this.boost;
this.y += this.speedY;
}
public double getSpeedY() { return this.speedY; }
public void setSpeedY(double speedY) { this.speedY = speedY; }
public double getBoost() { return this.boost; }
public void setBoost(double boost) { this.boost = boost; }
}