blob: 60bacfaf96a7c9fca4a9072ea1f6315a4ba1a834 (
plain)
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
|
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <ncurses.h>
#include "../rat.h"
#define width getmaxx(stdscr)
#define height getmaxy(stdscr)
int running;
int row = 1;
static void stop() {
clear();
refresh();
endwin();
running = 0;
}
void gameclicker(){
srand(time(NULL));
static int initialized = 0;
if(!initialized){ initscr();}else{refresh();}
++initialized;
noecho();
cbreak();
nodelay(stdscr, TRUE);
keypad(stdscr, TRUE);
curs_set(0);
int winh = height * 0.96;
int winw = width * 0.96;
int boxy = (height - winh) / 2;
int boxx = (width - winw) / 2;
WINDOW *win = newwin(winh, winw, boxy, boxx);
box(win, 0, 0); //box?
//should i wrap all this into a macro in rat.h to not have to write all of this every time i make a new game?
running = 1;
mvwprintw(win, row ++, 2, "hi");
while(running){
if(!running){stop();}
int ch = getch();
switch (ch) {
case 'q': case 'Q': stop(); break;
}
wrefresh(win);
usleep(16667); //60 fps according to google ai overview lmao
}
stop();
}
|