-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBullet.pde
69 lines (55 loc) · 1.13 KB
/
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class Bullet extends PlayerAttack {
static final int WIDTH = 12;
static final int HEIGHT = 8;
static final int SPEED = 18;
static final int DAMAGE = 30;
final color COLOR = color(200, 150, 0);
Bullet() {
this(false);
}
Bullet(boolean facingRight) {
super();
this.facingRight = facingRight;
if (facingRight) {
goingRight = true;
}
else {
goingLeft = true;
}
this.width = WIDTH;
this.height = HEIGHT;
this.fillColor = COLOR;
this.speed = SPEED;
}
int zIndex() {
return 10;
}
boolean hasGravity() {
return false;
}
int getDamage(Entity entity) {
if (this.deleted) {
return 0;
}
this.delete();
return DAMAGE;
}
void setVelocity() {
super.setVelocity();
Level.handleTileCollision(this);
}
void update() {
super.update();
}
void handleTileCollision() {
this.delete();
}
void handleEntityCollision(Entity other) {
if (other instanceof Enemy) {
this.delete();
}
}
void renderGraphics() {
Graphics.drawImage("bullet0.png", x, y, !facingRight);
}
}