-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeathState.pde
60 lines (49 loc) · 1.55 KB
/
DeathState.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
/*
* Copyright 2017 Billy Brown
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
class DeathState extends GameState {
public void onEnter(final Game game) {
}
public void input(final Game game, final char key) {
if (key == ' ') {
nextState = MenuState.class;
// Reset the game
game.reset();
}
}
public void click(final Game game, final PVector position) {
}
public void update(final Game game) {
}
public void draw(final Game game) {
textAlign(CENTER, TOP);
textSize(FONT_LARGE);
final int padding = 50;
int offset = 30;
text(game.getPlayer().name + " died...", displayWidth / 2, offset);
offset += FONT_LARGE * 2;
textAlign(LEFT, TOP);
textSize(FONT_MEDIUM);
final String[] messages = new String[] {
"Score: " + game.getPlayer().getScore(),
"Level: " + game.getPlayer().getLevel(),
"Depth: " + game.dungeonLevel,
"Stats: " + game.getPlayer().getStats(),
"Attack: " + game.getPlayer().getAttack(),
"Defence: " + game.getPlayer().getDefence()
};
for (final String message : messages) {
text(message, padding, offset);
offset += FONT_MEDIUM * 2;
}
textAlign(RIGHT, BOTTOM);
textSize(FONT_SMALL);
text("Press SPACE to return to the menu.", displayWidth - padding, displayHeight - padding);
}
public void resetTransition() {
nextState = DeathState.class;
}
}