-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStick.pde
56 lines (46 loc) · 971 Bytes
/
Stick.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
class Stick{
PVector[] coords = new PVector[2];
float dist = 20;
float d = 20;
float len = 400;
float r;
float angle;
float l = 0;
public Stick(float bRad){
r = bRad;
}
void charge(){
if(d<1000){
d = d + 5;
l = l + 1;
}
}
void hit(){
d = dist;
l = 0;
}
void trackCoords(PVector bPos){
float mx = mouseX;
float my = mouseY;
float x1 = 0, y1 = 0,
x2 = 0, y2 = 0;
angle = atan2(my-bPos.y,mx-bPos.x);
x1 = bPos.x + (r+d)*cos(angle);
y1 = bPos.y + (r+d)*sin(angle);
x2 = x1 + len*cos(angle);
y2 = y1 + len*sin(angle);
coords[0] = new PVector(x1,y1);
coords[1] = new PVector(x2,y2);
}
void showStick(){
stroke(180,100,40);
strokeWeight(10);
line(coords[0].x, coords[0].y,coords[1].x,coords[1].y);
stroke(255);
strokeWeight(0.2);
}
void show(PVector bPos){
trackCoords(bPos);
showStick();
}
}