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"
36 /* --- TITLE SCREEN --- */
40 texture_type title, anim1, anim2;
43 int done, quit, frame, pict, last_highscore;
47 level_editor_started = 0;
49 /* Init menu variables */
57 texture_load(&title,DATA_PREFIX "/images/title/title.png", IGNORE_ALPHA);
58 texture_load(&anim1,DATA_PREFIX "/images/title/title-anim2.png", IGNORE_ALPHA);
59 texture_load(&anim2,DATA_PREFIX "/images/title/title-anim1.png", IGNORE_ALPHA);
62 /* --- Main title loop: --- */
71 /* Draw the title background: */
72 texture_draw(&title, 0, 0, NO_UPDATE);
75 /* Draw the high score: */
76 last_highscore = load_hs();
77 sprintf(str, "High score: %d", last_highscore);
78 drawcenteredtext(str, 460, letters_red, NO_UPDATE, 1);
80 while (!done && !quit)
88 while (SDL_PollEvent(&event))
90 if (event.type == SDL_QUIT)
92 /* Quit event - quit: */
95 else if (event.type == SDL_KEYDOWN)
99 key = event.key.keysym.sym;
101 /* Check for menu events */
104 if (key == SDLK_ESCAPE)
112 else if (event.type == SDL_JOYAXISMOTION)
114 if (event.jaxis.value > 256)
115 menuaction = MN_DOWN;
119 else if (event.type == SDL_JOYBUTTONDOWN)
121 /* Joystick button: Continue: */
130 if(use_gl || menu_change)
132 /* Draw the title background: */
134 texture_draw_bg(&title, NO_UPDATE);
136 /* Draw the high score: */
137 sprintf(str, "High score: %d", last_highscore);
138 drawcenteredtext(str, 460, letters_red, NO_UPDATE, 1);
141 /* Don't draw menu, if quit is true */
142 if(show_menu && !quit)
145 if(game_started || level_editor_started)
148 /* Animate title screen: */
150 pict = (frame / 5) % 3;
153 texture_draw_part(&title, 560, 270, 80, 75, NO_UPDATE);
155 texture_draw(&anim1, 560, 270, NO_UPDATE);
157 texture_draw(&anim2, 560, 270, NO_UPDATE);
170 texture_free(&title);
171 texture_free(&anim1);
172 texture_free(&anim2);
175 /* Return to main! */