-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSpeedControl.pde
More file actions
49 lines (40 loc) · 931 Bytes
/
Copy pathSpeedControl.pde
File metadata and controls
49 lines (40 loc) · 931 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
class SpeedControl {
int state;
PImage imgSpeed1, imgSpeed2, imgSpeed3;
// TODO: put this in config
final int SPEED_MULTIPLIER_LOW = 1;
final int SPEED_MULTIPLIER_MED = 4;
final int SPEED_MULTIPLIER_HIGH = 16;
public SpeedControl() {
state = 0;
imgSpeed1 = loadImage("img/speed1.png");
imgSpeed2 = loadImage("img/speed2.png");
imgSpeed3 = loadImage("img/speed3.png");
}
public void incrementSpeed() {
if (state < 2) {
state++;
}
}
public void decrementSpeed() {
if (state > 0) {
state--;
}
}
public PImage getSpeedIcon() {
switch (state) {
case 0: return this.imgSpeed1;
case 1: return this.imgSpeed2;
case 2: return this.imgSpeed3;
default: return null;
}
}
public int getSpeed() {
switch (state) {
case 0: return this.SPEED_MULTIPLIER_LOW;
case 1: return this.SPEED_MULTIPLIER_MED;
case 2: return this.SPEED_MULTIPLIER_HIGH;
default: return 0;
}
}
}