forked from adamlamine/Piezo_Trilateration_Visual
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPiezo.pde
44 lines (38 loc) · 907 Bytes
/
Piezo.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
class Piezo{
float xPos;
float yPos;
float deltaTime = 0;
float deltaZeroTime = 0;
color c = color(0,0,0);
boolean collided = false;
Piezo(float xPos, float yPos){
this.xPos = xPos;
this.yPos = yPos;
}
boolean collides(SoundCircle sc){
if( dist(this.xPos, this.yPos, sc.xPos, sc.yPos) < sc.radius){
this.c = color(0,255,0);
this.collided = true;
if(!measurementStarted){
measurementStarted = true;
measurementStart = currentTime;
}
this.deltaTime = currentTime - measurementStart;
this.deltaZeroTime = currentTime - impactTime;
return true;
} else {
this.c = color(0,0,0);
return false;
}
}
void drawPiezo(){
fill(this.c);
circle(this.xPos, this.yPos, 50);
textSize(32);
fill(50);
}
void reset(){
this.c = color(0,0,0);
this.collided = false;
}
}