-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bullet.pde
48 lines (40 loc) · 929 Bytes
/
Bullet.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class Bullet extends Animated {
float size;
float x;
float y;
int dir;
float vel;
float yvel;
boolean hasCollided;
public Bullet(String filename, float scale, int direction, float speed, float ySpeed, float size, Sprite entity) {
super(filename, scale);
this.size = size;
standIdle = new PImage[14];
PImage bulletImg = loadImage("gfx/bullet.png");
hasCollided = false;
centreY = entity.centreY - entity.h/3.2;
this.vel = speed;
this.yvel = ySpeed;
super.w = 5;
super.h = 5;
standIdle[0] = bulletImg;
currentImages = standIdle;
if (direction == RIGHT_FACING) {
centreX = entity.getRight();
dir = 1;
}
if (direction == LEFT_FACING) {
centreX = entity.getLeft();
dir = -1;
}
}
void update() {
move();
}
void move() {
centreX += vel*dir;
centreY += yvel;
}
void setCollided(boolean b) {
}
}