-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollector.pde
39 lines (37 loc) · 894 Bytes
/
Collector.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
class Collector {
private int size;
private int x, y;
private int curLane;
StateManager2 stateManager2;
Collector(int s) {
stateManager2 = new StateManager2();
curLane = int(random(0, stateManager2.numLanes));
size = s;
x = stateManager2.paLeftX + stateManager2.gap*curLane - size/4;
y = height-size;
}
public void shiftRight() {
if (curLane < stateManager2.numLanes-1) {
curLane += 1;
x = stateManager2.paLeftX + stateManager2.gap*curLane - size/4;
}
}
public void shiftLeft() {
if (curLane > 0) {
curLane -= 1;
x = stateManager2.paLeftX + stateManager2.gap*curLane - size/4;
}
}
public void show() {
rect(x, y, size*.5, size);
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getSize() {
return size;
}
}