2022-06-08 16:23:57 +01:00
|
|
|
import java.awt.*;
|
2022-06-08 19:32:31 +01:00
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
import java.io.IOException;
|
2022-06-08 16:23:57 +01:00
|
|
|
|
|
|
|
public class Particle extends GenericSprite{
|
|
|
|
public static final int small = 3;
|
|
|
|
public static final int big = 10;
|
|
|
|
|
|
|
|
public int xVelocity;
|
|
|
|
|
|
|
|
public int yVelocity;
|
|
|
|
|
|
|
|
public int lifeSpan = 10;
|
2022-06-08 19:32:31 +01:00
|
|
|
|
|
|
|
public BufferedImage sprite;
|
|
|
|
|
|
|
|
public Particle(int x, int y, int xVelocity, int yVelocity, int length, String filePath) throws IOException {
|
|
|
|
super(x,y,length, length);
|
2022-06-08 16:23:57 +01:00
|
|
|
this.xVelocity = xVelocity;
|
|
|
|
this.yVelocity = yVelocity;
|
2022-06-08 19:32:31 +01:00
|
|
|
sprite = GamePanel.getImage(filePath);
|
2022-06-08 16:23:57 +01:00
|
|
|
}
|
|
|
|
public void move(){
|
|
|
|
x+=xVelocity;
|
|
|
|
y+=yVelocity;
|
2022-06-08 19:32:31 +01:00
|
|
|
yVelocity+=0.5;
|
2022-06-08 16:23:57 +01:00
|
|
|
}
|
|
|
|
public void draw(Graphics g){
|
2022-06-08 19:32:31 +01:00
|
|
|
g.drawImage(sprite,x-GamePanel.camera.x,y,WIDTH,HEIGHT, null);
|
2022-06-08 16:23:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|