{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Alien - import java.awt.Graphics import java.awt.Image A...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
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; // Amount alien drops down when it hits one side of canvas private final int DROP_DOWN_AMOUNT = 50; private final Sprite SPRITE; // Graphical representation of alien // VARIABLES private double upperLeftX, upperLeftY; // Position of alien on canvas private boolean leftToRight = true; private boolean moveDownRow = false; private int rowCount = 0; // Current horizontal speed. Positive moves right. Negative moves left. private double dx = .6; // Sound played when alien hit by missile private final String EXPLOSION_WAV = "explosion.wav"; // Object that plays the explosion sound. // This is analgous to SPRITE. One handles graphics details // the other audio details. private final Sound EXPLOSION; /* * Create a new alien object */
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}