-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.c
37 lines (26 loc) · 1.03 KB
/
ui.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
#include "ui.h"
#include <ncurses.h>
#include "player.h"
#include "map.h"
#include "draw.h"
#define UI_WINDOW_PLAYER_HEALTH_HEIGHT 1
#define UI_WINDOW_PLAYER_HEALTH_WIDTH 30
WINDOW *ui_window_player_health;
void ui_player_health_init() {
ui_window_player_health = newwin(1, UI_WINDOW_PLAYER_HEALTH_WIDTH+1, 1, screen_width - UI_WINDOW_PLAYER_HEALTH_WIDTH-3);
}
void ui_player_health() {
werase(ui_window_player_health);
window_rectangle_draw(ui_window_player_health, 0, 1, UI_WINDOW_PLAYER_HEALTH_HEIGHT, player_health*3-1, MAP_COLOR_HEALTHBAR_RED_CHARACTER, MAP_COLOR_HEALTHBAR_RED_PAIR);
for(int i = 0; i < 11; i++) {
wattron(ui_window_player_health, COLOR_PAIR(MAP_COLOR_HEALTHBAR_BLACK_COLOR));
mvwaddch(ui_window_player_health, 0, i*3, ' ');
wattroff(ui_window_player_health, COLOR_PAIR(MAP_COLOR_HEALTHBAR_BLACK_COLOR));
}
mvwaddch(ui_window_player_health, 0, 0, '[');
mvwaddch(ui_window_player_health, 0, UI_WINDOW_PLAYER_HEALTH_WIDTH, ']');
wnoutrefresh(ui_window_player_health);
}
void ui_draw() {
ui_player_health();
}