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"
37 /* --- TITLE SCREEN --- */
41 texture_type title, anim1, anim2;
44 int done, quit, frame, pict;
48 level_editor_started = 0;
50 /* Init menu variables */
58 texture_load(&title,DATA_PREFIX "/images/title/title.png", IGNORE_ALPHA);
59 texture_load(&anim1,DATA_PREFIX "/images/title/title-anim2.png", IGNORE_ALPHA);
60 texture_load(&anim2,DATA_PREFIX "/images/title/title-anim1.png", IGNORE_ALPHA);
63 /* --- Main title loop: --- */
72 /* Draw the title background: */
73 texture_draw(&title, 0, 0, NO_UPDATE);
76 /* Draw the high score: */
78 sprintf(str, "High score: %d", hs_score);
79 text_drawf(&gold_text, str, 0, -40, A_HMIDDLE, A_BOTTOM, 1, NO_UPDATE);
80 sprintf(str, "by %s", hs_name);
81 text_drawf(&gold_text, str, 0, -20, A_HMIDDLE, A_BOTTOM, 1, NO_UPDATE);
83 while (!done && !quit)
91 while (SDL_PollEvent(&event))
93 if (event.type == SDL_QUIT)
95 /* Quit event - quit: */
98 else if (event.type == SDL_KEYDOWN)
102 key = event.key.keysym.sym;
104 /* Check for menu events */
105 menu_event(&event.key.keysym);
107 if (key == SDLK_ESCAPE)
115 else if (event.type == SDL_JOYAXISMOTION && event.jaxis.axis == JOY_Y)
117 if (event.jaxis.value > 1024)
118 menuaction = MN_DOWN;
119 else if (event.jaxis.value < -1024)
122 else if (event.type == SDL_JOYBUTTONDOWN)
124 /* Joystick button: Continue: */
133 if(use_gl || menu_change)
135 /* Draw the title background: */
137 texture_draw_bg(&title, NO_UPDATE);
139 /* Draw the high score: */
140 sprintf(str, "High score: %d", hs_score);
141 text_drawf(&gold_text, str, 0, -40, A_HMIDDLE, A_BOTTOM, 1, NO_UPDATE);
142 sprintf(str, "by %s", hs_name);
143 text_drawf(&gold_text, str, 0, -20, A_HMIDDLE, A_BOTTOM, 1, NO_UPDATE);
147 /* Don't draw menu, if quit is true */
148 if(show_menu && !quit)
151 if(game_started || level_editor_started)
154 /* Animate title screen: */
156 pict = (frame / 5) % 3;
159 texture_draw_part(&title, 560, 270, 560, 270, 80, 75, NO_UPDATE);
161 texture_draw(&anim1, 560, 270, NO_UPDATE);
163 texture_draw(&anim2, 560, 270, NO_UPDATE);
176 texture_free(&title);
177 texture_free(&anim1);
178 texture_free(&anim2);
181 /* Return to main! */