-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEclipse.pde
97 lines (84 loc) · 2.4 KB
/
Eclipse.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
//import processing.sound.*;
//SoundFile soundFile;
final String GAME_TITLE = "Eclipse";
Menu menu;
Game game;
int display_mode;
final int MENU = 0;
final int TRANS_ONE = 1;
final int GAME = 2;
final int TRANS_TWO = 3;
int timer;
float nextPlayerRadius;
void setup() {
// orientation(LANDSCAPE);
size(1280, 730);
display_mode = MENU;
timer = millis();
menu = new Menu();
menu.setup();
}
void draw() {
switch(display_mode) {
case MENU:
menu.update();
menu.display();
if (menu.start) {
display_mode = TRANS_ONE;
menu.button.setPos((menu.button.x + menu.player.x)/2,
(menu.button.y + menu.player.y)/2);
menu.button.setStroke(null);
}
break;
case TRANS_ONE:
menu.player.radius += 10;
menu.button.setPos(mouseX, mouseY);
menu.transitionDisplay();
if (menu.player.encompassesScreen()) {
display_mode = GAME;
game = new Game();
game.setBackground(menu.player.circleFill);
game.player = new Player(menu.button);
game.target = new Target(game.player, game.gameBackground);
menu.clearObjects();
}
break;
case GAME:
game.update();
game.display();
if (game.player.encompasses(game.target)) {
nextPlayerRadius = game.player.radius;
display_mode = TRANS_TWO;
game.ghosts.add(new Ghost(game.player, game.target));
game.player.circleFill.a = 255;
} else {
Ghost toRemove = null;
for (Ghost g : game.ghosts) {
if (g.radius > game.player.radius && g.encompasses(game.player)) {
toRemove = g;
break;
}
}
if (toRemove != null) {
game.ghosts.remove(toRemove);
game.ghosts.add(new Ghost(game.player));
game.player = new Player(toRemove);
}
}
break;
case TRANS_TWO:
game.player.radius += 10;
game.target.setPos(mouseX, mouseY);
game.display();
if (game.player.encompassesScreen()) {
display_mode = GAME;
game.setBackground(game.player.circleFill);
game.player = new Player(game.target);
game.player.setRadius(nextPlayerRadius);
game.target = new Target(game.player, game.gameBackground);
}
break;
default:
throw new RuntimeException("Display mode '" + display_mode + "' not handled.");
}
}