-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dpad.pde
62 lines (58 loc) · 1.13 KB
/
Dpad.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class HatSW {
float x;
float y;
float r;
float R;
boolean enabled;
HatSW (float posx, float posy, float radius, float Radius) {
x = posx;
y = posy;
r = radius;
R = Radius;
enabled = false;
}
void update() {
if (gpad.getButton("Hat").pressed()) {
hatvalue = floor(gpad.getButton("Hat").getValue());
}
}
void show() {
int hue;
if (gpad.getButton("Hat").pressed()) {
hue = 64;
} else {
hue = 0;
}
stroke(255);
strokeWeight(1);
if (enabled) {
fill(hue, 255, 255);
} else {
fill(0, 0, 100);
}
ellipse(x, y, r, r);
noFill();
stroke(255, 200);
ellipse(x, y, R, R);
}
void showArrow() {
if (gpad.getButton("Hat").pressed()) {
pushMatrix();
translate(x, y);
rotate(TWO_PI*hatvalue/8.0+(1.0/2.0)*PI);
beginShape();
noStroke();
fill(64, 255, 255);
int hg = floor(R*0.4);
vertex(-4, hg+0);
vertex(4, hg+0);
vertex(4, hg+5);
vertex(6, hg+5);
vertex(0, hg+12);
vertex(-6, hg+5);
vertex(-4, hg+5);
endShape();
popMatrix();
}
}
}