The task is to be able to move the alien right, down, and left. So far all i can get the alien to do is move right and down. I need to get it to be able to move left. Can you help me please?
import java.awt.Graphics;
import java.awt.Image;
/**
* A single alien in the Space Invaders game.
*
* @author Kevin Glass
*/
class Alien {
// CONSTANTS
private final String ALIEN_ICON = "alien.gif";
private final int MAX_WIDTH; // Size of canvas on which Alien is moving
private final int MAX_HEIGHT;
// Initial speed at which the alien moves horizontally
private final double INITIAL_X_SPEED = 0.5; // NOT an int - must be double
private final Sprite SPRITE; // Graphical representation of alien
// VARIABLES
private double upperLeftX, upperLeftY; // Position of alien on canvas
/*
* Create a new alien object - Constructor
*/
public Alien(int theX, int theY, int theMaxWidth, int theMaxHeight) {
upperLeftX = theX;
upperLeftY = theY;
MAX_WIDTH = theMaxWidth;
MAX_HEIGHT = theMaxHeight;
// Get the graphical representation of the alien
SPRITE = SpriteStore.get().getSprite(ALIEN_ICON);
}
public void draw(Graphics g) {
SPRITE.draw(g, (int) upperLeftX, (int) upperLeftY);
}
public void move() {
int x = MAX_WIDTH;
x = 700;
if (upperLeftX >= x){
upperLeftY++;
}
if (upperLeftX <= x){
upperLeftX++;
}