#define FPS 50
int lives;
-long score;
+long score = 0, hiscore = 0;
int status; // status handled in timer
int weite;
-int level;
+int level = 0, hilevel = 0;
int skill_level;
#define GAME_LOOP 1
argv += optind;
}
+const char *rating(int score)
+{
+
+ if(score<5000)
+ return "Alien Fodder";
+ else if(score<7500)
+ return "Easy Target";
+ else if(score<10000)
+ return "Barely Mediocre";
+ else if(score<12500)
+ return "Shows Promise";
+ else if(score<15000)
+ return "Alien Blaster";
+ else if(score<20000)
+ return "Earth Defender";
+ else if(score>19999)
+ return "Supreme Protector";
+ else return "Unknown";
+}
static void finish(int sig)
{
fprintf(stderr,"\n");
fprintf(stderr,"=========================================================================\n");
fprintf(stderr,"\n");
-
- fprintf(stderr,"Final score: %7.7ld, Final level: %2.2d\nFinal rating... ",score,level);
+
+ if (hiscore > 0)
+ fprintf(stderr, " High score: %7.7ld, Level: %2.2d, Rating: %s\n",
+ hiscore, hilevel, rating(hiscore));
+ fprintf(stderr, "Final score: %7.7ld, Final level: %2.2d\nFinal rating... ",score,level);
if (lives>0)
- fprintf(stderr,"Quitter\n\n");
- else if(score<5000)
- fprintf(stderr,"Alien Fodder\n\n");
- else if(score<7500)
- fprintf(stderr,"Easy Target\n\n");
- else if(score<10000)
- fprintf(stderr,"Barely Mediocre\n\n");
- else if(score<12500)
- fprintf(stderr,"Shows Promise\n\n");
- else if(score<15000)
- fprintf(stderr,"Alien Blaster\n\n");
- else if(score<20000)
- fprintf(stderr,"Earth Defender\n\n");
- else if(score>19999)
- fprintf(stderr,"Supreme Protector\n\n");
-
+ fprintf(stderr,"Quitter, ");
+ fprintf(stderr, "%s\n\n", rating(score));
+
showVersion();
exit(0);
}
#include "view.h"
#include "globals.h"
+#include "nInvaders.h"
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
{",^,", "_O-", "-o-", "o=o", "<O>", "_x_", "*^*", "\\_/", "o o"},
{".-.", "-O_", "/o\\", "o-o", "<o>", "-x-", "o^o", "/~\\", "oo "}
};
- int score[3] = {200, 150, 100};
+ int scores[3] = {200, 150, 100};
int colors[9] = {RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE};
char buffer[12];
static int alien_type = 0;
}
for (i = alien_type; i < alien_type + 3; i++) {
waddstr(wAliens, " ");
- snprintf(buffer, sizeof(buffer), "%s = %d", aliens[frame % 2][i], score[i % 3]);
+ snprintf(buffer, sizeof(buffer), "%s = %d", aliens[frame % 2][i], scores[i % 3]);
wattrset(wAliens, COLOR_PAIR(colors[i]));
waddstr(wAliens, buffer);
}
x = (SCREENWIDTH / 2) - (20 / 2);
y = SCREENHEIGHT - 2;
copywin(wStartText, wTitleScreen, 0, 0, y, x, y, x + 19, 0);
-
+
+ /*
+ * A bit ridiculous to use pads or everything, especially when leaking
+ * them after each game to display the title screen again. Let's not
+ * follow the routine, then let's actually add delwin(3) below for the
+ * above pads that used to leak.
+ */
+ if (score != 0) {
+ wattrset(wTitleScreen, COLOR_PAIR(BLUE));
+ mvwprintw(wTitleScreen, SCREENHEIGHT - 7, 12,
+ "Last score: %7.7ld", score);
+ mvwprintw(wTitleScreen, SCREENHEIGHT - 6, 12,
+ "Last level: %2.2d", level);
+ mvwprintw(wTitleScreen, SCREENHEIGHT - 5, 16,
+ "Rating: %s", rating(score));
+
+ if (score > hiscore) {
+ hiscore = score;
+ hilevel = level;
+ }
+ }
+ if (hiscore != 0) {
+ wattrset(wTitleScreen, COLOR_PAIR(MAGENTA));
+ mvwprintw(wTitleScreen, SCREENHEIGHT - 7, SCREENWIDTH - 31,
+ "High score: %7.7ld", hiscore);
+ mvwprintw(wTitleScreen, SCREENHEIGHT - 6, SCREENWIDTH - 29,
+ "At level: %2.2d", hilevel);
+ mvwprintw(wTitleScreen, SCREENHEIGHT - 5, SCREENWIDTH - 27,
+ "Rating: %s", rating(hiscore));
+ }
+
copywin(wTitleScreen, wBattleField, 0, 0, 0, 0, SCREENHEIGHT-1, SCREENWIDTH-1, 0);
-
wrefresh(wBattleField);
+
+ delwin(wStartText);
+ delwin(wAliens);
+ delwin(wTitleText);
}