4 Super Tux - Intro Screen
7 bill@newbreedsoftware.com
8 http://www.newbreedsoftware.com/supertux/
10 April 11, 2000 - March 15, 2004
19 #include <SDL_image.h>
21 #include <sys/types.h>
31 char * intro_text[] = {
32 "Tux and Gown were having a nice picnic..",
34 "Gown is beamed away!!!",
35 "This looks like a job for ---"
44 texture_type bkgd, copter_squish, copter_stretch, beam,
45 gown_sit, gown_lookup, gown_upset,
46 tux_sit, tux_upset, tux_mad;
47 texture_type copter[2];
49 int done, i, quit, j, scene;
50 int * height, * height_speed;
53 /* Load sprite images: */
54 texture_load(&bkgd, datadir + "/images/intro/intro.png", IGNORE_ALPHA);
55 texture_load(&gown_sit, datadir + "/images/intro/gown-sit.png", USE_ALPHA);
56 texture_load(&gown_lookup, datadir + "/images/intro/gown-lookup.png", USE_ALPHA);
57 texture_load(&gown_upset, datadir + "/images/intro/gown-upset.png", USE_ALPHA);
58 texture_load(&tux_sit, datadir + "/images/intro/tux-sit.png", USE_ALPHA);
59 texture_load(&tux_upset, datadir + "/images/intro/tux-upset.png", USE_ALPHA);
60 texture_load(&tux_mad, datadir + "/images/intro/tux-mad.png", USE_ALPHA);
61 texture_load(&copter[0], datadir + "/images/intro/copter1.png", USE_ALPHA);
62 texture_load(&copter[1], datadir + "/images/intro/copter2.png", USE_ALPHA);
63 texture_load(&copter_squish, datadir + "/images/intro/copter-squish.png", USE_ALPHA);
64 texture_load(&copter_stretch, datadir + "/images/intro/copter-stretch.png", USE_ALPHA);
65 texture_load(&beam, datadir + "/images/intro/beam.png", USE_ALPHA);
67 /* Allocate buffer for height array: */
69 height = (int*) malloc(sizeof(int) * (gown_upset.w));
70 height_speed = (int*) malloc(sizeof(int) * (gown_upset.w));
73 /* Initialize height arrays: */
75 for (j = 0; j < (gown_upset.w); j++)
78 height_speed[j] = (rand() % 10) + 1;
81 /* Display background: */
83 texture_draw_bg(&bkgd, UPDATE);
92 timer_init(&timer, false);
93 timer_start(&timer,10000);
95 while (timer_check(&timer) && !done && !quit)
99 done = wait_for_event(event,0);
107 /* Display background: */
111 if (timer_get_gone(&timer) < 2000 && scene == 0)
114 /* Gown and tux sitting: */
116 texture_draw(&tux_sit, 270, 400, UPDATE);
117 texture_draw(&gown_sit, 320, 400, UPDATE);
119 text_drawf(&white_text, intro_text[0], 0, -8, A_HMIDDLE, A_BOTTOM, 0);
123 if (timer_get_gone(&timer) >= 2000 && scene == 1)
126 /* Helicopter begins to fly in: */
128 erasecenteredtext(&white_text, intro_text[0], 454, &bkgd, NO_UPDATE, 1);
129 text_drawf(&white_text, intro_text[1], 0,-8, A_HMIDDLE, A_BOTTOM, 0);
133 if (timer_get_gone(&timer) >= 2000 && timer_get_gone(&timer) < 4000)
135 /* Helicopter flying in: */
136 texture_draw_part(&bkgd,0,32, 0, 32, screen->w, (copter[0].h));
138 texture_draw(&copter[i % 2],
139 (float)(timer_get_gone(&timer) - 2000) / 5 - (copter[0].w), 32,
142 update_rect(screen, 0, 32, screen->w, (copter[0].h));
146 if (timer_get_gone(&timer) >= 2500 && scene == 2)
149 /* Gown notices something... */
151 texture_draw(&gown_lookup, 320, 400, UPDATE);
155 if (timer_get_gone(&timer) >= 3500 && scene == 3)
158 /* Gown realizes it's bad! */
160 texture_draw(&gown_upset, 320, 400, UPDATE);
164 if (timer_get_gone(&timer) >= 4000 && timer_get_gone(&timer) < 8000)
166 /* Helicopter sits: */
167 texture_draw_part(&bkgd,0,32, 0, 32, screen->w, (copter[0].h));
169 texture_draw(&copter[i % 2], 400 - (copter[0].w), 32);
170 update_rect(screen, 0, 32, screen->w, (copter[0].h));
174 if (timer_get_gone(&timer) >= 5000 && scene == 4)
177 /* Tux realizes something's happening: */
179 texture_draw(&tux_upset, 270, 400, UPDATE);
182 erasecenteredtext(&white_text, intro_text[1], 454, &bkgd, UPDATE, 1);
183 text_drawf(&white_text, intro_text[2], 0,-8, A_HMIDDLE, A_BOTTOM, 0);
187 if (timer_get_gone(&timer) >= 5000 && timer_get_gone(&timer) <= 8000)
191 texture_draw_part(&bkgd,
192 310, 32 + (copter[0].h), 310,
195 376 + (gown_upset.h) - (copter[0].h));
198 for (j = 0; j < (gown_upset.sdl_surface -> w); j++)
200 texture_draw(&beam, 320 + j - ((beam.w) / 2), height[j],
206 src.h = (gown_upset.h);
213 texture_draw_part(&gown_upset,src.x,src.y,dest.x,dest.y,dest.w,dest.h);
215 height[j] = 400 + rand() % 10 - (int)(300. * ((float)(timer_get_gone(&timer) - 5000)/(float)3000.));
224 400 + (gown_upset.h) - (copter[0].h));
228 if (timer_get_gone(&timer) >= 8000 && scene == 5)
230 texture_draw_part(&bkgd,
231 310, 32 + (copter[0].h), 310,
234 368 + (gown_upset.h) - (copter[0].h));
239 texture_draw(&tux_mad, 270, 400, UPDATE);
241 erasecenteredtext(&white_text, intro_text[2], 454, &bkgd, UPDATE, 1);
242 text_drawf(&white_text, intro_text[3], 0,-8, A_HMIDDLE, A_BOTTOM, 0);
246 if (timer_get_gone(&timer) >= 8000 && timer_get_gone(&timer) <= 8250)
248 /* Helicopter starting to speed off: */
250 texture_draw_part(&bkgd, 0, 32, 0, 32, screen->w, (copter_squish.h));
252 texture_draw(&copter_squish,
253 400 - (copter[0].w), 32,
256 update_rect(screen, 0, 32, screen->w, (copter_squish.h));
260 if (timer_get_gone(&timer) >= 8250)
262 /* Helicopter speeding off: */
264 texture_draw_part(&bkgd, 0, 32, 0, 32, screen->w, (copter_stretch.h));
266 texture_draw(&copter_stretch,
267 (timer_get_gone(&timer) - 8250) /*(i - (8250 / FPS)) * 30*/ + 400 - (copter[0].w),
271 update_rect(screen, 0, 32, screen->w, (copter_stretch.h));
285 texture_free(&gown_sit);
286 texture_free(&gown_lookup);
287 texture_free(&gown_upset);
288 texture_free(&tux_sit);
289 texture_free(&tux_upset);
290 texture_free(&tux_mad);
291 texture_free(&copter[0]);
292 texture_free(&copter[1]);
293 texture_free(&copter_squish);
294 texture_free(&copter_stretch);
298 /* Free array buffers: */
304 /* Return to main! */