By using this site, you agree to our Privacy Policy and our Terms of Use. Close

Bluuet Class

import java.util.Random;
import javax.swing.ImageIcon;
public class Bullet extends Body {

static final ImageIcon bullet = new ImageIcon("bullet.png");

static final Integer width = bullet.getIconWidth();

static final Integer height = bullet.getIconHeight();

// public Double yVelocity = y-SpaceShip.y;
// public Double xVelocity = x-SpaceShip.x;
// public Double yVelocity = SpaceShip.top();
public double yvelocity = Game.ship.getY();

public Double yVelocity = 3.0;
public Double xVelocity = 3.0;

public Bullet(Double xp, Double yp) {
x = xp;
y = yp;
}

public void draw(Game h, GameComponent canvas) {
canvas.drawImage(bullet.getImage(), mapx(h, canvas, x), mapy(h, canvas,
y));
}

public Boolean offscreen() {
return y > SpaceInvaders.ycanvas;
}

public void step(Game bw, GameComponent canvas) { // All they do is drop.
y += yVelocity;
x += xVelocity;
}

public Double width() {
return (double) width;
}

public Double height() {
return (double) height;
}
}