import java.awt.Point; abstract class MovableObject extends GameObject { int direction; int speed; Point previousLocation; MovableObject(int d, int s, Point loc) { super(loc); this.direction = d; this.speed = s; this.previousLocation = loc; } void update() { this.moveForward(); this.draw(); } public String toString() { return super.toString() + " facing " + this.direction + " degrees"; } void moveForward() { this.previousLocation = new Point(this.location.x, this.location.y); if (this.speed > 0) /*this.location.translate((int)(Math.cos(Math.toRadians(this.direction)) * this.speed), (int)(Math.sin(Math.toRadians(this.direction)) * this.speed));*/ // Negate the y value for GameBoard display to adjust for the Top/Left (0,0) origin this.location.translate((int)(Math.cos(Math.toRadians(this.direction)) * this.speed), -(int)(Math.sin(Math.toRadians(this.direction)) * this.speed)); } abstract void draw(); }