4 Super Tux - Title Screen
7 bill@newbreedsoftware.com
8 http://www.newbreedsoftware.com/supertux/
10 April 11, 2000 - December 9, 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;
47 /* Init menu variables */
55 title = load_image(DATA_PREFIX "/images/title/title.png", IGNORE_ALPHA);
56 anim1 = load_image(DATA_PREFIX "/images/title/title-anim2.png",
58 anim2 = load_image(DATA_PREFIX "/images/title/title-anim1.png",
62 /* --- Main title loop: --- */
71 /* Draw the title background: */
72 drawimage(title, 0, 0, UPDATE);
75 /* Draw the high score: */
76 sprintf(str, "High score: %d", load_hs());
77 drawcenteredtext(str, 460, letters_red, UPDATE);
79 while (!done && !quit)
86 while (SDL_PollEvent(&event))
88 if (event.type == SDL_QUIT)
90 /* Quit event - quit: */
94 else if (event.type == SDL_KEYDOWN)
98 key = event.key.keysym.sym;
100 if (key == SDLK_ESCAPE)
107 else if (event.type == SDL_KEYUP)
109 key = event.key.keysym.sym;
110 /* Check for menu events */
114 else if (event.type == SDL_JOYAXISMOTION)
116 if (event.jaxis.value > 256)
117 menuaction = MN_DOWN;
121 else if (event.type == SDL_JOYBUTTONDOWN)
123 /* Joystick button: Continue: */
134 /* Draw the title background: */
136 drawimage(title, 0, 0, UPDATE);
138 /* Draw the high score: */
139 sprintf(str, "High score: %d", load_hs());
140 drawcenteredtext(str, 460, letters_red, UPDATE);
143 /* Don't draw menu, if quit is true */
144 if(show_menu && !quit)
150 /* Animate title screen: */
152 pict = (frame / 5) % 3;
155 drawpart(title, 560, 270, 80, 75, UPDATE);
157 drawimage(anim1, 560, 270, UPDATE);
159 drawimage(anim2, 560, 270, UPDATE);
172 SDL_FreeSurface(title);
173 SDL_FreeSurface(anim1);
174 SDL_FreeSurface(anim2);
177 /* Return to main! */