-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlood.pde
57 lines (48 loc) · 1.06 KB
/
Blood.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
class Blood extends GameObject
{
float timeToLive;
float theta;
float alive;
float speed = 3;
boolean active;
float elapsed;
float splatHeight;
float splatWidth;
Blood(float x, float y, float theta, float size, float timeToLive)
{
pos = new PVector(x, y);
forward = new PVector(0,1);
this.theta = theta;
this.size = size;
this.timeToLive = timeToLive;
this.alive = 0;
this.active = true;
this.elapsed = 0;
this.splatHeight = random(10, 60);
this.splatWidth = random(3, 50);
}
void render()
{
pushMatrix();
translate((pos.x+(forward.x*30))-5, pos.y+(forward.y*30));
rotate(theta);
fill(255, 0, 0);
noStroke();
ellipse(0, 0, this.splatWidth, this.splatHeight);
popMatrix();
if(elapsed < timeToLive) {
update();
}
elapsed += timeDelta;
if(elapsed > 10)
{
gameObjects.remove(this);
}
}
void update()
{
forward.x = -sin(theta);
forward.y = cos(theta);
pos.add(PVector.mult(PVector.mult(forward, speed), 5));
}
}