-
Notifications
You must be signed in to change notification settings - Fork 0
/
Input.pde
74 lines (67 loc) · 1.27 KB
/
Input.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
63
64
65
66
67
68
69
70
71
72
73
74
void keyPressed() {
switch(key) {
case 'w':
keys[0] = true;
break;
case 'a':
keys[1] = true;
break;
case 's':
keys[2] = true;
break;
case 'd':
keys[3] = true;
break;
}
}
void keyReleased() {
switch(key) {
case 'w':
keys[0] = false;
break;
case 'a':
keys[1] = false;
break;
case 's':
keys[2] = false;
break;
case 'd':
keys[3] = false;
break;
}
}
float[] bufferKeys() {
float moveX = 0;
float moveY = 0;
if(keys[0]) {
moveY -= 1;
}
if(keys[1]) {
moveX -= 1;
}
if(keys[2]) {
moveY += 1;
}
if(keys[3]) {
moveX += 1;
}
return new float[] {moveX, moveY};
}
void mousePressed() {
if(buttons.get(0).isClicked()) {
float newSpeed = ((ButtonValueChanger)buttons.get(0)).click(bulletSpeed, 2.0, 1.0, 30.0);
for(Bullet b : bullets) {
b.speed = newSpeed;
}
bulletSpeed = newSpeed;
}
else if(buttons.get(1).isClicked()) {
float newSpeed = ((ButtonValueChanger)buttons.get(1)).click(ship.speed, 2, 1, 50);
ship.setSpeed(newSpeed);
}
else if(buttons.get(2).isClicked()) {
ButtonToggle b = (ButtonToggle)buttons.get(2);
b.click();
bulletsDisappearOnImpact = b._pressed;
}
}