-
Notifications
You must be signed in to change notification settings - Fork 0
/
CatcherTutorial.pde
73 lines (66 loc) · 1.49 KB
/
CatcherTutorial.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
/*
Main entry CatcherTutorial application.
by Flocksserver http://flocksserver.de
*/
final int stateWaitToStart = 0;
final int stateGameRunning = 1;
final int stateWaitToRestart = 2;
final int stateHighscoreRunning = 3;
final int stateGameRestart = 4;
int state = stateWaitToStart;
Startscreen startscreen;
Game game;
Highscore highscore;
PFont normalFont;
PFont bigFont;
float playerPosX;
float playerPosY;
float gameHeight;
float gameWidth;
float textWidth;
float textWidthBig;
float scale;
//background
color darkGrey = color(45, 50, 50);
color yellow = color(255, 255, 0);
void setup() {
fullScreen(P2D);
gameWidth = width;
gameHeight = height;
//On Desktop
scale = 1 + gameWidth/1000;
//On Android
//scale = displayDensity;
textWidth = 22;
textWidthBig = 100;
normalFont = createFont("SansSerif", textWidth * scale);
bigFont = createFont("SansSerif", textWidthBig * scale);
startscreen = new Startscreen();
game = new Game();
highscore = new Highscore();
}
void draw() {
background(darkGrey);
if (mousePressed) {
playerPosX = mouseX;
playerPosY = mouseY;
}
if (state == stateWaitToStart) {
startscreen.execute();
}
if (state == stateGameRunning) {
game.execute();
}
if (state == stateWaitToRestart) {
playerPosX = 0;
playerPosY = 0;
state = stateHighscoreRunning;
}
if (state == stateHighscoreRunning) {
highscore.execute(game.score);
}
if (state == stateGameRestart) {
game.init();
state = stateGameRunning;
}
}