12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <curses.h>
- #include <unistd.h>
- #include <time.h>
- #include "game.h"
- #include "endscreen.h"
- int main(int argc, char** argv) {
- if (! initscr()) {
- endwin();
- fprintf(stderr, "Snek: Error initializing ncurses\n");
- exit(1);
- }
- start_color();
-
- init_pair(1, COLOR_WHITE, COLOR_WHITE);
- init_pair(2, COLOR_WHITE, COLOR_CYAN);
- init_pair(3, COLOR_WHITE, COLOR_MAGENTA);
- init_pair(4, COLOR_WHITE, COLOR_RED);
- init_pair(5, COLOR_WHITE, COLOR_BLUE);
- init_pair(6, COLOR_WHITE, COLOR_YELLOW);
- init_pair(7, COLOR_WHITE, COLOR_BLACK);
-
- srandom(time( (time_t *) 0 ));
-
- keypad(stdscr, TRUE);
- nodelay(stdscr, TRUE);
- noecho();
- cbreak();
- curs_set(0);
-
- while (1) {
- GAME_STATE* state = malloc(sizeof(GAME_STATE));
- play_game(state);
- display_endscreen(state -> points);
- free(state);
- }
- endwin();
- //printf("GAME OVER! POINTS: %d\n", state -> points);
- free(state);
-
- return 0;
- }
|