import java.awt.image.ImageObserver; import java.awt.Image; import java.awt.Graphics; import java.awt.image.BufferedImage; public class Shot { private int x; private int y; private int speed; private int angle; private int damage; private BufferedImage pic; private long timeFired; private int xFired; private int yFired; public Shot() { this.x = 0; this.y = 0; this.speed = 0; this.damage = 0; this.pic = null; this.timeFired = System.currentTimeMillis(); this.xFired = 0; this.yFired = 0; } public Shot(final int newX, final int newY, final int newDamage, final int newSpeed, final BufferedImage newPic) { this.x = newX; this.y = newY; this.speed = newSpeed; this.damage = newDamage; this.pic = newPic; this.timeFired = System.currentTimeMillis(); this.xFired = newX; this.yFired = newY; } public void draw(final Graphics g) { this.y = (int)(this.yFired + (System.currentTimeMillis() - this.timeFired) * this.speed / 1000L); g.drawImage(this.pic, this.x - this.pic.getWidth() / 2, this.y - this.pic.getHeight() / 2, null); } public boolean outOfBounds() { return this.y + this.pic.getHeight() / 2 < 0 || this.y - this.pic.getHeight() / 2 > 600 || (this.x + this.pic.getWidth() / 2 < 0 || this.x - this.pic.getWidth() / 2 > 800); } public int getX() { return this.x; } public int getY() { return this.y; } public int getSpeed() { return this.speed; } public int getDamage() { return this.damage; } public BufferedImage getPic() { return this.pic; } public void setX(final int newX) { this.x = newX; } public void setY(final int newY) { this.y = newY; } }