From: Matthew Mondor Date: Tue, 11 Apr 2023 04:19:46 +0000 (+0000) Subject: Minor code cleanup and properly reset player position when changing X-Git-Url: http://git.pulsar-zone.net/?a=commitdiff_plain;h=3387624b8565f77cccf31bbb2fff1be8c9c7e487;p=curblaster.git Minor code cleanup and properly reset player position when changing level or restarting a new game. --- diff --git a/src/main.cpp b/src/main.cpp index 264d193..6e4688d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -88,9 +88,10 @@ cleanup(void) * are received, the input queue can start filling with only one character * processed per frame, delaying actions to user commands. For this reason, * when a successful character is received, the input queue is also cleared. - * XXX For some reason, despite using this method the game appears to - * accelerate a bit at user input, although less drasticly than it used to - * with only halfdelay(3), as originally implemented. + * Depending on the curses implementation and port, it is possible for polling + * with an excessive delay to occur, causing the clock to accelerate when user + * input occurs, but still less than with the original halfdelay(3) based + * clock. */ static int frame_getch(void) @@ -564,6 +565,7 @@ int main(int argc, char *argv[]){ missiles[missileloop].chase = -1; }; + if ((win = initscr()) == NULL) err(EXIT_FAILURE, "initscr()"); @@ -575,6 +577,15 @@ int main(int argc, char *argv[]){ }; (void)atexit(cleanup); + (void)cbreak(); + (void)noecho(); + (void)nonl(); + (void)leaveok(win, FALSE); + (void)keypad(win, TRUE); + (void)intrflush(stdscr, FALSE); + (void)curs_set(0); + (void)timeout(0); + int loopvar = 0; int podcount = 0; @@ -588,15 +599,6 @@ int main(int argc, char *argv[]){ int smartbombs = 2; int drawlaser = 0; - (void)cbreak(); - (void)noecho(); - (void)nonl(); - (void)leaveok(win, FALSE); - (void)keypad(win, TRUE); - (void)intrflush(stdscr, FALSE); - (void)curs_set(0); - (void)timeout(0); - //print title screen @@ -1840,10 +1842,7 @@ int main(int argc, char *argv[]){ lives = 4; //Reset level level = 1; - //Drop shields - /* XXX - shieldup = 0; - */ + //Temporary supershield tempshield(); player.speed = 0; player.vspeed = 0; @@ -1893,6 +1892,12 @@ int main(int argc, char *argv[]){ }; score = 0; newgame = 0; + // Reset position and speed + drawlocation = 0; + player.x = 8; + player.y = 35; + player.speed = 0; + player.vspeed = 0; }; //lander pod grab logic @@ -1996,10 +2001,12 @@ int main(int argc, char *argv[]){ //Advance level level++; - //Drop shields XXX - //shieldup = 0; + //Temporary supershield tempshield(); - // Reset speed + // Reset position and speed + drawlocation = 0; + player.x = 8; + player.y = 35; player.speed = 0; player.vspeed = 0; //Reactivate pods if not zombied