*/
#include <err.h>
-#include <ncurses.h>
+#include <curses.h>
#include <cstring>
#include <cstdlib>
#include <cstdio>
static void cleanup(void);
static int frame_getch(void);
-static int halfdelay_getch(void);
int block_getch(void);
{
int c;
- (void)curs_set(0);
-
(void)usleep(1000000 / ANIM_FPS);
- (void)keypad(win, TRUE);
- (void)timeout(0);
-
- c = wgetch(win);
+ c = getch();
if (c != ERR)
(void)flushinp();
return c;
}
-static int
-halfdelay_getch(void)
-{
-
- (void)halfdelay(1);
- (void)curs_set(1);
-
- return wgetch(win);
-}
-
int
block_getch(void)
{
+ int c;
- (void)timeout(-1);
(void)curs_set(1);
+ (void)timeout(-1);
+
+ c = getch();
+
+ (void)curs_set(0);
+ (void)timeout(0);
- return wgetch(win);
+ return c;
}
err(EXIT_FAILURE, "initscr()");
//Check screen size 80x24 and exit if not big enough
- int maxx, maxy;
-
- getmaxyx(stdscr, maxx, maxy);
-
- if(maxx<24||maxy<80){
+ if(LINES<24||COLS<80){
endwin();
- printf("Screen only %d x %d, needs to be at least 80x24\n", maxy, maxx);
- exit(1);
+ printf("Screen only %d x %d, needs to be at least 80x24\n", COLS, LINES);
+ exit(EXIT_FAILURE);
};
(void)atexit(cleanup);
cbreak();
noecho();
nonl();
+ (void)keypad(win, TRUE);
+ (void)intrflush(stdscr, FALSE);
+ (void)curs_set(0);
+ (void)timeout(0);
+
//print title screen
mvprintw(13,34,"High Score: %d",hscore);
- //get the cursor out of the way
- mvprintw(23,79,"-");
-
//load sound, music
#ifdef __USE_SDL__
Mix_Chunk *shotsound = NULL;
int counter = 0;
int show_controls = 30;
while(pause_game!=' '){
- pause_game = halfdelay_getch();
+ pause_game = frame_getch();
if(counter>=4){
//GO!
mvprintw(18,28,"Press SPACE to start");
show_controls--;
};
- //get the cursor out of the way
- mvprintw(23,79,"|");
-
// Sleeps for a frame then checks for any input
input = frame_getch();
};
};
};
- //wrefresh(win);
+ refresh();
}; //end main loop
#ifdef __USE_SDL__