4 Super Tux - Title Screen
7 bill@newbreedsoftware.com
8 http://www.newbreedsoftware.com/supertux/
10 April 11, 2000 - December 29, 2003
19 #include <SDL_image.h>
23 #include <sys/types.h>
31 #include "high_scores.h"
35 /* --- TITLE SCREEN --- */
39 SDL_Surface * title, * anim1, * anim2;
42 int done, quit, frame, pict, last_highscore;
46 level_editor_started = 0;
48 /* Init menu variables */
56 title = load_image(DATA_PREFIX "/images/title/title.png", IGNORE_ALPHA);
57 anim1 = load_image(DATA_PREFIX "/images/title/title-anim2.png",
59 anim2 = load_image(DATA_PREFIX "/images/title/title-anim1.png",
63 /* --- Main title loop: --- */
72 /* Draw the title background: */
73 drawimage(title, 0, 0, NO_UPDATE);
76 /* Draw the high score: */
77 last_highscore = load_hs();
78 sprintf(str, "High score: %d", last_highscore);
79 drawcenteredtext(str, 460, letters_red, NO_UPDATE, 1);
81 while (!done && !quit)
88 while (SDL_PollEvent(&event))
90 if (event.type == SDL_QUIT)
92 /* Quit event - quit: */
96 else if (event.type == SDL_KEYDOWN)
100 key = event.key.keysym.sym;
102 /* Check for menu events */
105 if (key == SDLK_ESCAPE)
113 else if (event.type == SDL_JOYAXISMOTION)
115 if (event.jaxis.value > 256)
116 menuaction = MN_DOWN;
120 else if (event.type == SDL_JOYBUTTONDOWN)
122 /* Joystick button: Continue: */
133 /* Draw the title background: */
135 drawimage(title, 0, 0, NO_UPDATE);
137 /* Draw the high score: */
138 sprintf(str, "High score: %d", last_highscore);
139 drawcenteredtext(str, 460, letters_red, NO_UPDATE, 1);
142 /* Don't draw menu, if quit is true */
143 if(show_menu && !quit)
146 if(game_started || level_editor_started)
149 /* Animate title screen: */
151 pict = (frame / 5) % 3;
154 drawpart(title, 560, 270, 80, 75, NO_UPDATE);
156 drawimage(anim1, 560, 270, NO_UPDATE);
158 drawimage(anim2, 560, 270, NO_UPDATE);
172 SDL_FreeSurface(title);
173 SDL_FreeSurface(anim1);
174 SDL_FreeSurface(anim2);
177 /* Return to main! */