-
Notifications
You must be signed in to change notification settings - Fork 0
/
Culminating.pde
executable file
·150 lines (145 loc) · 4.19 KB
/
Culminating.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
int gameState = 0; //MENU, PREGAME, GAME, PAUSE, BADEND, GOODEND
GameManager manager = new GameManager();
Menu menu = new Menu();
Player player;
HashMap templates = new HashMap(); //This would normally go inside Timeline, but can't make static fields because of processing.
Window window;
PauseMenu pause;
int tickTime;
EndMenu endMenu = new EndMenu();
int up_key = 0, down_key = 0, left_key = 0, right_key = 0, shift_key = 0, z_key = 0, x_key = 0, esc_key = 0;
int left = 25, right = 375, top = 25, bottom = 575; //If you change these god help anybody who made any levels because they don't conform to the standard.
void setup() {
size(600, 600); //DO NOT change the screen size. It will do nothing, as there's no scaling.
gameState = 0;
window = new Window(left, right, top, bottom);
frameRate(60);
player = new Player();
pause = new PauseMenu();
}
int phase, stage;
void draw() {
tickTime = millis();
//Cleanup, then pick stage, then run as it will.
switch(gameState){
case 0: //Menu
background(0);
menu.draw();
break;
case 1: //Pregame setup, run only once, unless failed for whatever reason.
window.reset();
if(manager.start()){
println("Started");
menu.reset();
pause.reset();
gameState = 2;
}else{
gameState = 0;
menu.reset();
break;
}
case 2: //Game
background(200);
manager.resume();
manager.tick();
window.draw();
break;
case 3: //Pause, just for fun.
background(200);
manager.pause();
manager.tick();
window.draw();
pause.draw();
break;
case 4://Both of these are Ends, but one's bad end and the other's good end.
case 5:
background(0);
endMenu.draw();
break;
default:
break;
}
}
void keyPressed() { //Handle keypresses. Releases set to zero, but don't update it if it's held and other parts change the variable to something other than 0 or 1.
if (key == CODED) {
switch(keyCode) {
case UP:
up_key = up_key == 0 ? 1 : up_key;
break;
case DOWN:
down_key = down_key == 0 ? 1 : down_key;
break;
case LEFT:
left_key = left_key == 0 ? 1 : left_key;
break;
case RIGHT:
right_key = right_key == 0 ? 1 : right_key;
break;
case SHIFT:
shift_key = shift_key == 0 ? 1 : shift_key;
break;
}
} else {
switch(key) {
case 'Z'://Four, because I'm also running on Dvorak and don't want to change layouts to play.
case 'z':
case ';':
case ':':
z_key = z_key == 0 ? 1 : z_key;
println("z hit");
break;
case 'X':
case 'x':
case 'q':
case 'Q':
x_key = x_key == 0 ? 1 : x_key;
println("x hit");
break;
case ESC:
println("esc hit");
esc_key = esc_key == 0 ? 1 : esc_key;
key = 0;
break;
}
}
}
void keyReleased() { //And key releases.
if (key == CODED) {
switch(keyCode) {
case UP:
up_key = 0;
break;
case DOWN:
down_key = 0;
break;
case LEFT:
left_key = 0;
break;
case RIGHT:
right_key = 0;
break;
case SHIFT:
shift_key = 0;
break;
}
} else {
switch(key) {
case 'Z':
case 'z':
case ';':
case ':':
z_key = 0;
break;
case 'X':
case 'x':
case 'q':
case 'Q':
x_key = 0;
break;
case ESC:
esc_key = 0;
key = 0;
break;
}
}
}