-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathmain.cpp
50 lines (44 loc) · 1.02 KB
/
main.cpp
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
/* Main Loop for cataclysm
* Linux only I guess
* But maybe not
* Who knows
*/
#if (defined _WIN32 || defined WINDOWS)
#include "catacurse.h"
#else
#include <curses.h>
#endif
#include <ctime>
#include "game.h"
#include "color.h"
#include "options.h"
#include "mapbuffer.h"
int main(int argc, char *argv[])
{
srand(time(NULL));
// ncurses stuff
initscr(); // Initialize ncurses
noecho(); // Don't echo keypresses
cbreak(); // C-style breaks (e.g. ^C to SIGINT)
keypad(stdscr, true); // Numpad is numbers
init_colors(); // See color.cpp
curs_set(0); // Invisible cursor
rand(); // For some reason a call to rand() seems to be necessary to avoid
// repetion.
bool quit_game = false;
game *g = new game;
MAPBUFFER = mapbuffer(g);
MAPBUFFER.load();
load_options();
do {
g->setup();
while (!g->do_turn());
if (g->game_quit())
quit_game = true;
} while (!quit_game);
MAPBUFFER.save();
erase(); // Clear screen
endwin(); // End ncurses
system("clear"); // Tell the terminal to clear itself
return 0;
}