-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircle.cpp
More file actions
52 lines (46 loc) · 781 Bytes
/
Circle.cpp
File metadata and controls
52 lines (46 loc) · 781 Bytes
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
#include "SnakeElement.h"
void Circle::setX(int &x) {
X = x;
}
void Circle::setY(int &y) {
Y = y;
}
void Circle::getXYR(int &x, int &y, int &r) {
x = X;
y = Y;
r = R;
}
void Circle::goUp() {
if (Y < 0) {
Y = 64;
}
Y -= 2 * R;
}
void Circle::goDown() {
if (Y > 64) {
Y = 0;
}
Y += 2 * R;
}
void Circle::goLeft() {
if (X < 0) {
X = 128;
}
X -= 2 * R;
}
void Circle::goRight() {
if (X > 128) {
X = 0;
}
X += 2 * R;
}
void Circle::draw() {
display.fillCircle(X, Y, R, WHITE);
//display.drawCircle(X, Y, R, BLACK);
}
bool Circle::intersects(Circle &Other) {
int xOther, yOther, rOther;
Other.getXYR(xOther, yOther, rOther);
int distance = ((X - xOther) ^ 2 + (Y - yOther) ^ 2);
return distance < ((R + rOther) ^ 2);
}