Alien - import java.awt.Graphics; import java.awt.Image; /*...

Info iconThis 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;
Background image of page 1

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

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

This note was uploaded on 06/10/2011 for the course COMP 110 taught by Professor Stotts during the Spring '08 term at UNC.

Page1 / 3

Alien - import java.awt.Graphics; import java.awt.Image; /*...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online