-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlock.pde
More file actions
53 lines (47 loc) · 945 Bytes
/
Block.pde
File metadata and controls
53 lines (47 loc) · 945 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
53
// Chris Acker
// December 18, 2016
class Block {
float x = 0;
float y = 0;
float xspeed = 1;
float yspeed = 0;
boolean score(PVector pos) {
float d = dist(x, y, pos.x, pos.y);
if (d < 1) {
return true;
} else {
return false;
}
}
void dir(float x, float y) {
xspeed = x;
yspeed = y;
}
// how should death be handled?
void death() {
}
void update() {
//println(total + " " + tail.size());
x = x + xspeed*scl;
y = y + yspeed*scl;
// if square goes "out of bounds", circle back around
if (x > width && xspeed > 0) {
x = 0;
} else if (x < 0 && xspeed < 0) {
x = width;
} else if (y < 0 && yspeed < 0) {
y = width;
} else if (y > width && yspeed > 0) {
y = 0;
}
}
//
void show() {
if (blocks.get(currBlock).equals(this)) {
fill(0, 0, 255);
} else {
fill(255);
}
rect(x, y, scl, scl);
}
}