-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
53 lines (49 loc) · 1008 Bytes
/
main.c
File metadata and controls
53 lines (49 loc) · 1008 Bytes
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
#ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h>
#include "webcurses.h"
#else
#include <ncurses.h>
#endif
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#define UI_COLOR_WHITE 1
#define UI_COLOR_RED 2
#define UI_COLOR_BLUE 3
#define UI_COLOR_GREEN 4
#define UI_COLOR_YELLOW 5
#define UI_MAX_COLORS 6
void init_colors() {
if (has_colors())
{
start_color();
init_pair(UI_COLOR_WHITE, COLOR_WHITE, -1);
init_pair(UI_COLOR_RED, COLOR_RED, -1);
init_pair(UI_COLOR_BLUE, COLOR_BLUE, -1);
init_pair(UI_COLOR_GREEN, COLOR_GREEN, -1);
init_pair(UI_COLOR_YELLOW, COLOR_YELLOW, -1);
}
}
int main() {
srand(time(NULL));
initscr();
noecho();
curs_set(0);
use_default_colors();
init_colors();
char ch;
int frames=0;
for(;;) {
timeout(1000/60);
ch = getch();
if (ch == 'q') {
break;
}
if (ch != ERR) {
clear();
mvaddch(random() % 15 + 1, random() % 25 + 1, ch | COLOR_PAIR(random() % (UI_MAX_COLORS - 1) + 1));
}
frames++;
}
endwin();
}