3 // SuperTux - A Jump'n Run
4 // Copyright (C) 2000 Bill Kendrick <bill@newbreedsoftware.com>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include <SDL_image.h>
28 #include <sys/types.h>
38 char * intro_text[] = {
39 "Tux and Gown were having a nice picnic..",
41 "Gown is beamed away!!!",
42 "This looks like a job for ---"
51 texture_type bkgd, copter_squish, copter_stretch, beam,
52 gown_sit, gown_lookup, gown_upset,
53 tux_sit, tux_upset, tux_mad;
54 texture_type copter[2];
56 int done, i, quit, j, scene;
57 int * height, * height_speed;
60 /* Load sprite images: */
61 texture_load(&bkgd, datadir + "/images/intro/intro.png", IGNORE_ALPHA);
62 texture_load(&gown_sit, datadir + "/images/intro/gown-sit.png", USE_ALPHA);
63 texture_load(&gown_lookup, datadir + "/images/intro/gown-lookup.png", USE_ALPHA);
64 texture_load(&gown_upset, datadir + "/images/intro/gown-upset.png", USE_ALPHA);
65 texture_load(&tux_sit, datadir + "/images/intro/tux-sit.png", USE_ALPHA);
66 texture_load(&tux_upset, datadir + "/images/intro/tux-upset.png", USE_ALPHA);
67 texture_load(&tux_mad, datadir + "/images/intro/tux-mad.png", USE_ALPHA);
68 texture_load(&copter[0], datadir + "/images/intro/copter1.png", USE_ALPHA);
69 texture_load(&copter[1], datadir + "/images/intro/copter2.png", USE_ALPHA);
70 texture_load(&copter_squish, datadir + "/images/intro/copter-squish.png", USE_ALPHA);
71 texture_load(&copter_stretch, datadir + "/images/intro/copter-stretch.png", USE_ALPHA);
72 texture_load(&beam, datadir + "/images/intro/beam.png", USE_ALPHA);
74 /* Allocate buffer for height array: */
76 height = (int*) malloc(sizeof(int) * (gown_upset.w));
77 height_speed = (int*) malloc(sizeof(int) * (gown_upset.w));
80 /* Initialize height arrays: */
82 for (j = 0; j < (gown_upset.w); j++)
85 height_speed[j] = (rand() % 10) + 1;
88 /* Display background: */
90 texture_draw_bg(&bkgd, 255, UPDATE);
102 while (timer.check() && !done && !quit)
106 done = wait_for_event(event,0);
114 /* Display background: */
118 if (timer.get_gone() < 2000 && scene == 0)
121 /* Gown and tux sitting: */
123 texture_draw(&tux_sit, 270, 400, 255, UPDATE);
124 texture_draw(&gown_sit, 320, 400, 255, UPDATE);
126 text_drawf(&white_text, intro_text[0], 0, -8, A_HMIDDLE, A_BOTTOM, 0);
130 if (timer.get_gone() >= 2000 && scene == 1)
133 /* Helicopter begins to fly in: */
135 erasecenteredtext(&white_text, intro_text[0], 454, &bkgd, NO_UPDATE, 1);
136 text_drawf(&white_text, intro_text[1], 0,-8, A_HMIDDLE, A_BOTTOM, 0);
140 if (timer.get_gone() >= 2000 && timer.get_gone() < 4000)
142 /* Helicopter flying in: */
143 texture_draw_part(&bkgd,0,32, 0, 32, screen->w, (copter[0].h));
145 texture_draw(&copter[i % 2],
146 (float)(timer.get_gone() - 2000) / 5 - (copter[0].w), 32);
148 update_rect(screen, 0, 32, screen->w, (copter[0].h));
152 if (timer.get_gone() >= 2500 && scene == 2)
155 /* Gown notices something... */
157 texture_draw(&gown_lookup, 320, 400, 255, UPDATE);
161 if (timer.get_gone() >= 3500 && scene == 3)
164 /* Gown realizes it's bad! */
166 texture_draw(&gown_upset, 320, 400, 255, UPDATE);
170 if (timer.get_gone() >= 4000 && timer.get_gone() < 8000)
172 /* Helicopter sits: */
173 texture_draw_part(&bkgd,0,32, 0, 32, screen->w, (copter[0].h));
175 texture_draw(&copter[i % 2], 400 - (copter[0].w), 32);
176 update_rect(screen, 0, 32, screen->w, (copter[0].h));
180 if (timer.get_gone() >= 5000 && scene == 4)
183 /* Tux realizes something's happening: */
185 texture_draw(&tux_upset, 270, 400, 255, UPDATE);
188 erasecenteredtext(&white_text, intro_text[1], 454, &bkgd, UPDATE, 1);
189 text_drawf(&white_text, intro_text[2], 0,-8, A_HMIDDLE, A_BOTTOM, 0);
193 if (timer.get_gone() >= 5000 && timer.get_gone() <= 8000)
197 texture_draw_part(&bkgd,
198 310, 32 + (copter[0].h), 310,
201 376 + (gown_upset.h) - (copter[0].h));
204 for (j = 0; j < (gown_upset.sdl_surface -> w); j++)
206 texture_draw(&beam, 320 + j - ((beam.w) / 2), height[j]);
211 src.h = (gown_upset.h);
218 texture_draw_part(&gown_upset,src.x,src.y,dest.x,dest.y,dest.w,dest.h);
220 height[j] = 400 + rand() % 10 - (int)(300. * ((float)(timer.get_gone() - 5000)/(float)3000.));
229 400 + (gown_upset.h) - (copter[0].h));
233 if (timer.get_gone() >= 8000 && scene == 5)
235 texture_draw_part(&bkgd,
236 310, 32 + (copter[0].h), 310,
239 368 + (gown_upset.h) - (copter[0].h));
244 texture_draw(&tux_mad, 270, 400, UPDATE);
246 erasecenteredtext(&white_text, intro_text[2], 454, &bkgd, UPDATE, 1);
247 text_drawf(&white_text, intro_text[3], 0,-8, A_HMIDDLE, A_BOTTOM, 0);
251 if (timer.get_gone() >= 8000 && timer.get_gone() <= 8250)
253 /* Helicopter starting to speed off: */
255 texture_draw_part(&bkgd, 0, 32, 0, 32, screen->w, (copter_squish.h));
257 texture_draw(&copter_squish,
258 400 - (copter[0].w), 32);
260 update_rect(screen, 0, 32, screen->w, (copter_squish.h));
264 if (timer.get_gone() >= 8250)
266 /* Helicopter speeding off: */
268 texture_draw_part(&bkgd, 0, 32, 0, 32, screen->w, (copter_stretch.h));
270 texture_draw(&copter_stretch,
271 (timer.get_gone() - 8250) /*(i - (8250 / FPS)) * 30*/ + 400 - (copter[0].w),
274 update_rect(screen, 0, 32, screen->w, (copter_stretch.h));
296 delete copter_squish;
297 delete copter_stretch;
301 /* Free array buffers: */
307 /* Return to main! */