-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathst_message.c
53 lines (38 loc) · 931 Bytes
/
st_message.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
#include "st_message.h"
#include <ncurses.h>
#include <string.h>
#include "ui.h"
#include "const.h"
#include "input.h"
#include "audio.h"
float msg_timer;
void st_message_enter(game_t *game)
{
clear();
msg_timer = 0;
ui_draw_border();
int line_height = 4;
int height = game->msg.lines_len * line_height;
int y = HEIGHT / 2 - (height / 2);
attron(COLOR_PAIR(PAIR_WHITE));
for (int i = 0; i < game->msg.lines_len; i++)
{
const char *line = game->msg.lines[i];
int width = strlen(line);
move(y + i * line_height, WIDTH / 2 - width / 2);
addstr(line);
}
attroff(COLOR_PAIR(PAIR_WHITE));
audio_sound_play(SOUND_MSG);
}
void st_message_run(game_t *game, float delta)
{
msg_timer += delta;
if (msg_timer > 5 * 1000000 || CURR_KEY != ERR)
{
sm_set_state(game->msg.next_state);
}
}
void st_message_exit(game_t *game)
{
}