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, last_highscore;
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 last_highscore = load_hs();
77 sprintf(str, "High score: %d", last_highscore);
78 drawcenteredtext(str, 460, letters_red, UPDATE);
80 while (!done && !quit)
87 while (SDL_PollEvent(&event))
89 if (event.type == SDL_QUIT)
91 /* 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: */
132 /* Draw the title background: */
134 drawimage(title, 0, 0, UPDATE);
136 /* Draw the high score: */
137 sprintf(str, "High score: %d", last_highscore);
138 drawcenteredtext(str, 460, letters_red, UPDATE);
141 /* Don't draw menu, if quit is true */
142 if(show_menu && !quit)
148 /* Animate title screen: */
150 pict = (frame / 5) % 3;
153 drawpart(title, 560, 270, 80, 75, UPDATE);
155 drawimage(anim1, 560, 270, UPDATE);
157 drawimage(anim2, 560, 270, UPDATE);
170 SDL_FreeSurface(title);
171 SDL_FreeSurface(anim1);
172 SDL_FreeSurface(anim2);
175 /* Return to main! */