#include "screen.h"
#include "sound.h"
#include "setup.h"
+#include "high_scores.h"
/* Sound files: */
/* Local variables: */
-int score, distros, level, lives, scroll_x, next_level,
+int score, highscore, distros, level, lives, scroll_x, next_level,
tux_dir, tux_size, tux_duck, tux_x, tux_xm, tux_y, tux_ym,
tux_dying, tux_safe, jumping, jump_counter, frame, score_multiplier,
tux_frame_main, tux_frame, tux_got_coffee, tux_skidding,
void add_upgrade(int x, int y, int kind);
void killtux(int mode);
void add_bullet(int x, int y, int dir, int xm);
+void drawendscreen(void);
/* --- GAME LOOP! --- */
loadlevel();
loadlevelgfx();
loadlevelsong();
+ highscore = load_hs();
/* --- MAIN GAME LOOP!!! --- */
/* No more lives!? */
- if (lives <= 0)
+ if (lives < 0)
{
+ drawendscreen();
+ if (score > highscore)
+ save_hs(score);
- /* Display end-of-level stuff */
- /* (FIXME: This should go in its own event loop function!) */
-
- clearscreen(0, 0, 0);
-
- drawcenteredtext("GAMEOVER", 200, letters_red, NO_UPDATE);
-
- sprintf(str, "SCORE: %d", score);
- drawcenteredtext(str, 224, letters_gold, NO_UPDATE);
-
- sprintf(str, "DISTROS: %d", distros);
- drawcenteredtext(str, 256, letters_blue, NO_UPDATE);
-
- SDL_Flip(screen);
- SDL_Delay(5000);
-
-
- /* FIXME: Should return to title screen, not restart game... */
-
- level = 0;
- lives = 3;
-
- score=0;
- distros=0;
+ return(0);
}
sprintf(str, "%d", score);
drawtext("SCORE", 0, 0, letters_blue, NO_UPDATE);
drawtext(str, 96, 0, letters_gold, NO_UPDATE);
+
+ sprintf(str, "%d", highscore);
+ drawtext("HIGH", 0, 20, letters_blue, NO_UPDATE);
+ drawtext(str, 80, 20, letters_gold, NO_UPDATE);
if (time_left >= 50 || (frame % 10) < 5)
{
playsound(sounds[SND_SHOOT]);
#endif
}
+
+
+void drawendscreen(void)
+{
+ char str[80];
+
+ clearscreen(0, 0, 0);
+
+ drawcenteredtext("GAMEOVER", 200, letters_red, NO_UPDATE);
+
+ sprintf(str, "SCORE: %d", score);
+ drawcenteredtext(str, 224, letters_gold, NO_UPDATE);
+
+ sprintf(str, "DISTROS: %d", distros);
+ drawcenteredtext(str, 256, letters_blue, NO_UPDATE);
+
+ SDL_Flip(screen);
+ SDL_Delay(2000);
}
+
bill@newbreedsoftware.com
http://www.newbreedsoftware.com/supertux/
- April 11, 2000 - April 12, 2000
+ April 11, 2000 - December 9, 2003
*/
#include <stdio.h>
#include "globals.h"
#include "title.h"
#include "screen.h"
+#include "high_scores.h"
/* --- TITLE SCREEN --- */
SDL_Event event;
SDLKey key;
int done, quit, frame, pict;
+ char str[80];
/* Clear screen: */
/* Draw the title background: */
drawimage(title, 0, 0, UPDATE);
+
+
+ /* Draw the high score: */
+
+ sprintf(str, "High score: %d", load_hs());
+ drawcenteredtext(str, 460, letters_red, UPDATE);
/* --- Main title loop: --- */