-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.c
105 lines (86 loc) · 2.05 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
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
96
97
98
99
100
101
102
103
104
105
#include "ui.h"
#include <ncurses.h>
#include "const.h"
#include "statemachine.h"
#define DEBUG 0
void ui_draw_help()
{
const char *lines[19];
lines[0] = "Your goal is to get";
lines[1] = "your positive energy";
lines[2] = "over 30, so you can";
lines[3] = "ascend from this 2D";
lines[4] = "plane and move to more";
lines[5] = "amicable dimensions";
lines[6] = "";
lines[7] = "Income is calculated";
lines[8] = "after every encounter:";
lines[9] = "";
lines[10] = "Bad Vibes subtract from";
lines[11] = "Good Vibes";
lines[12] = "";
lines[13] = "Good Vibes add to";
lines[14] = "positive energy and can";
lines[15] = "go negative.";
lines[16] = "";
lines[17] = "Positive energy adds";
lines[18] = "to power.";
int x = WIDTH - RIGHT_PANEL_WIDTH + 3;
int y = HEIGHT - BOTTOM_PANEL_HEIGHT - 21;
attron(COLOR_PAIR(PAIR_WHITE));
for (int i = 0; i < 19; i++)
{
move(y + i, x);
addstr(lines[i]);
}
attroff(COLOR_PAIR(PAIR_WHITE));
}
void ui_draw_border()
{
attron(COLOR_PAIR(1));
move(0, 0);
vline('*', HEIGHT);
hline('*', WIDTH);
move(0, 5);
addstr("CHAD'S WORLD V 0.1");
move(HEIGHT, 0);
hline('*', WIDTH);
move(0, WIDTH);
vline('*', HEIGHT);
attroff(COLOR_PAIR(1));
}
void ui_draw_debug(float delta)
{
if (!DEBUG)
{
return;
}
attron(COLOR_PAIR(2));
move(1, WIDTH + 3);
char buffer[32];
snprintf(buffer, 32, "FPS: %f", 1000000.0 / delta);
addstr(buffer);
move(2, WIDTH + 3);
snprintf(buffer, 32, "STATE: %d", sm_dbg_getstate());
addstr(buffer);
attroff(COLOR_PAIR(2));
}
void ui_draw_sprite(int x, int y, const char **lines, int len)
{
for (int i = 0; i < len; i++)
{
move(i + y, x);
addstr(lines[i]);
}
}
void ui_clear_sprite(int x, int y, int width, int height)
{
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
move(y + i, x + j);
addstr(" ");
}
}
}