-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnemyProjectile.pde
67 lines (58 loc) · 1.09 KB
/
EnemyProjectile.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
class EnemyProjectile
{
// FIELDS:
PVector pos, vel, dim;
boolean isAlive;
// CONSTRUCTOR:
EnemyProjectile(PVector pos, PVector vel)
{
this.pos = pos;
this.vel = vel;
isAlive = true;
dim = new PVector(10, 5);
}
void update()
{
drawProjectile();
move();
checkWalls();
}
// METHODS:
void drawProjectile()
{
if (removeBeam == false)
{
pushMatrix();
fill(5, 249, 255);
translate(pos.x, pos.y);
rect(0, 0, 80, dim.x, dim.y);
popMatrix();
}
}
void move()
{
if (removeBeam == false)
{
pos.add(vel);
}
}
void checkWalls()
{
if (pos.x < 0 || pos.x > width || pos.y < 0 || pos.y > height)
{
isAlive = false;
}
}
void hit(Player ironman)
{
if ((abs(pos.x - (ironman.pos.x + 127)) < dim.x / 2 + ironman.size.x / 2 && abs(pos.y - (ironman.pos.y + 138)) < dim.y / 2 + ironman.size.y / 2))
{
ironman.decreaseHealth(50);
isAlive = false;
//if (enemy.health <= -3)
//{
// enemy.vel.add(-5, -5);
//}
}
}
} // class end