-
Notifications
You must be signed in to change notification settings - Fork 1
/
Mouse.pde
44 lines (37 loc) · 881 Bytes
/
Mouse.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
// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
// Exercise 10-4: The raindrop catching game
class Mouse {
float r; // radius
color col; // color
float x, y; // location
Mouse(float tempR) {
r = tempR;
col = color(50, 10, 10, 150);
x = 0;
y = 0;
}
void setLocation(float tempX, float tempY) {
x = tempX;
y = tempY;
}
void display() {
stroke(0);
fill(col);
image(mouse1, x-50 + random(0, 4), y-100 + random(0, 4), 110, 110);
//ellipse(x, y, r*2, r*2);
}
// A function that returns true or false based on
// if the catcher intersects a raindrop
boolean intersect(Drop d) {
// Calculate distance
float distance = dist(x, y, d.x, d.y);
// Compare distance to sum of radii
if (distance < r + d.r) {
return true;
} else {
return false;
}
}
}