-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathst_score.c
62 lines (48 loc) · 1.46 KB
/
st_score.c
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
#include "st_score.h"
#include <ncurses.h>
#include <string.h>
#include "states.h"
#include "const.h"
#include "ui.h"
#include "input.h"
#include "audio.h"
static float score_timer;
void st_score_enter(game_t *game)
{
score_timer = 0;
const char *win_line1 = "Wow. Look at you go. You've built up enough positive energy to break free from the shackles of 2D existence.";
const char *win_line2 = "Congratulations. Enjoy your enlightenment.";
const char *loss_line1 = "Oof. Not only did you fail to ascend, you've built up so much negative energy you'll be stuck in 2D for eternity";
const char *loss_line2 = "Too bad. Try again!";
clear();
ui_draw_border();
attron(COLOR_PAIR(PAIR_YELLOW));
if (game->energy > 0)
{
move(HEIGHT / 2 - 2, WIDTH / 2 - strlen(win_line1) / 2);
addstr(win_line1);
move(HEIGHT / 2 + 2, WIDTH / 2 - strlen(win_line2) / 2);
addstr(win_line2);
audio_music_play(MUSIC_WIN);
}
else
{
move(HEIGHT / 2 - 2, WIDTH / 2 - strlen(loss_line1) / 2);
addstr(loss_line1);
move(HEIGHT / 2 + 2, WIDTH / 2 - strlen(loss_line2) / 2);
addstr(loss_line2);
audio_music_play(MUSIC_LOSS);
}
attroff(COLOR_PAIR(PAIR_YELLOW));
}
void st_score_run(game_t *game, float delta)
{
score_timer += delta;
if (score_timer > 30 * 1000000 || CURR_KEY != ERR)
{
sm_set_state(STATE_MENU);
}
}
void st_score_exit(game_t *game)
{
}