Bullet - SPRITE = SpriteStore.get().getSprite(BULLET_ICON);...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.awt.Graphics; import java.awt.Image; public class Bullet { //Constants private final String BULLET_ICON = "missile.gif"; private final int MAX_WIDTH;//size of the canvas on which the bullet moves. private final int MAX_HEIGHT; private final double INITIAL_Y_SPEED = 1; //Variables private double upperLeftX, upperLeftY;//Position of the bullet at its upper left corner. private final Sprite SPRITE; //graphical representation of the bullet. public Bullet(double theX, int theY, int theMaxWidth, int theMaxHeight){ upperLeftX = theX; upperLeftY = theY; MAX_WIDTH = theMaxWidth; MAX_HEIGHT = theMaxHeight;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: SPRITE = SpriteStore.get().getSprite(BULLET_ICON); } public void draw(Graphics g, double canonX) { SPRITE.draw(g, (int) upperLeftX, (int) upperLeftY); setUpperLeftX(canonX); } public double getHeight(){ return SPRITE.getHeight(); } public void move(){ upperLeftY = upperLeftY - INITIAL_Y_SPEED; if(upperLeftY<0) upperLeftY = MAX_HEIGHT; } public double getX(){ return upperLeftX; } public double getY(){ return upperLeftY; } public void setUpperLeftX(double x){ upperLeftX = x; } public void setUpperLeftY(int y){ upperLeftY = y; } }...
View Full Document

Ask a homework question - tutors are online