intro.c
Super Tux - Intro Screen
-
+
by Bill Kendrick
bill@newbreedsoftware.com
http://www.newbreedsoftware.com/supertux/
- April 11, 2000 - April 23, 2000
+ April 11, 2000 - February 1st, 2004
*/
#include <stdio.h>
#include "globals.h"
#include "intro.h"
#include "screen.h"
-#include "type.h"
+#include "texture.h"
+#include "timer.h"
char * intro_text[] = {
"Tux and Gown were having a nice picnic..",
/* Load sprite images: */
-
texture_load(&bkgd, DATA_PREFIX "/images/intro/intro.png", IGNORE_ALPHA);
texture_load(&gown_sit, DATA_PREFIX "/images/intro/gown-sit.png", USE_ALPHA);
texture_load(&gown_lookup, DATA_PREFIX "/images/intro/gown-lookup.png", USE_ALPHA);
/* Allocate buffer for height array: */
- height = malloc(sizeof(int) * (gown_upset.w));
- height_speed = malloc(sizeof(int) * (gown_upset.w));
+ height = (int*) malloc(sizeof(int) * (gown_upset.w));
+ height_speed = (int*) malloc(sizeof(int) * (gown_upset.w));
/* Initialize height arrays: */
texture_draw(&tux_sit, 270, 400, UPDATE);
texture_draw(&gown_sit, 320, 400, UPDATE);
- drawcenteredtext(intro_text[0], 456, letters_blue, UPDATE, 1);
+ text_drawf(&white_text, intro_text[0], 0, -8, A_HMIDDLE, A_BOTTOM, 0, NO_UPDATE);
}
++scene;
/* Helicopter begins to fly in: */
- erasecenteredtext(intro_text[0], 456, bkgd.sdl_surface, NO_UPDATE, 1);
- drawcenteredtext(intro_text[1], 456, letters_red, NO_UPDATE, 1);
+ erasecenteredtext(&white_text, intro_text[0], 454, &bkgd, NO_UPDATE, 1);
+ text_drawf(&white_text, intro_text[1], 0,-8, A_HMIDDLE, A_BOTTOM, 0, NO_UPDATE);
}
if (timer_get_gone(&timer) >= 2000 && timer_get_gone(&timer) < 4000)
{
/* Helicopter flying in: */
- texture_draw_part(&bkgd, 0, 32, screen->w, (copter[0].h), NO_UPDATE);
+ texture_draw_part(&bkgd,0,32, 0, 32, screen->w, (copter[0].h), NO_UPDATE);
texture_draw(&copter[i % 2],
(float)(timer_get_gone(&timer) - 2000) / 5 - (copter[0].w), 32,
if (timer_get_gone(&timer) >= 4000 && timer_get_gone(&timer) < 8000)
{
/* Helicopter sits: */
- texture_draw_part(&bkgd, 0, 32, screen->w, (copter[0].h), NO_UPDATE);
+ texture_draw_part(&bkgd,0,32, 0, 32, screen->w, (copter[0].h), NO_UPDATE);
texture_draw(&copter[i % 2], 400 - (copter[0].w), 32, NO_UPDATE);
update_rect(screen, 0, 32, screen->w, (copter[0].h));
texture_draw(&tux_upset, 270, 400, UPDATE);
- erasecenteredtext(intro_text[1], 456, bkgd.sdl_surface, UPDATE, 1);
- drawcenteredtext(intro_text[2], 456, letters_red, UPDATE, 1);
+ erasecenteredtext(&white_text, intro_text[1], 454, &bkgd, UPDATE, 1);
+ text_drawf(&white_text, intro_text[2], 0,-8, A_HMIDDLE, A_BOTTOM, 0, NO_UPDATE);
}
- if (timer_get_gone(&timer) >= 5000)
+ if (timer_get_gone(&timer) >= 5000 && timer_get_gone(&timer) <= 8000 && height[j] != 105)
{
/* Beam gown up! */
texture_draw_part(&bkgd,
- 320,
+ 310, 32 + (copter[0].h), 310,
32 + (copter[0].h),
- (gown_upset.w),
- 368 + (gown_upset.h) - (copter[0].h), NO_UPDATE);
+ (gown_upset.w) + 20,
+ 378 + (gown_upset.h) - (copter[0].h), NO_UPDATE);
for (j = 0; j < (gown_upset.sdl_surface -> w); j++)
dest.w = src.w;
dest.h = src.h;
- SDL_BlitSurface(gown_upset.sdl_surface, &src, screen, &dest);
+ texture_draw_part(&gown_upset,src.x,src.y,dest.x,dest.y,dest.w,dest.h,NO_UPDATE);
- height[j] = height[j] - height_speed[j];
+ height[j] = 400 + rand() % 10 - (int)(300. * ((float)(timer_get_gone(&timer) - 5000)/(float)3000.));
+ if(height[j] < 105)
+ height[j] = 105;
- if ((i % 2) == 0)
- height_speed[j]++;
+ height_speed[j] = (float)(timer_get_gone(&timer) - 5000) / 300.;
}
update_rect(screen,
- 320,
+ 310,
32 + (copter[0].h),
- (gown_upset.w),
+ (gown_upset.w) + 20,
400 + (gown_upset.h) - (copter[0].h));
}
if (timer_get_gone(&timer) >= 8000 && scene == 5)
{
+ texture_draw_part(&bkgd,
+ 310, 32 + (copter[0].h), 310,
+ 32 + (copter[0].h),
+ (gown_upset.w) + 20,
+ 368 + (gown_upset.h) - (copter[0].h), NO_UPDATE);
+
++scene;
/* Tux gets mad! */
texture_draw(&tux_mad, 270, 400, UPDATE);
- erasecenteredtext(intro_text[2], 456, bkgd.sdl_surface, UPDATE, 1);
- drawcenteredtext(intro_text[3], 456, letters_gold, UPDATE, 1);
+ erasecenteredtext(&white_text, intro_text[2], 454, &bkgd, UPDATE, 1);
+ text_drawf(&white_text, intro_text[3], 0,-8, A_HMIDDLE, A_BOTTOM, 0, NO_UPDATE);
}
{
/* Helicopter starting to speed off: */
- texture_draw_part(&bkgd, 0, 32, screen->w, (copter_squish.h), NO_UPDATE);
+ texture_draw_part(&bkgd, 0, 32, 0, 32, screen->w, (copter_squish.h), NO_UPDATE);
texture_draw(&copter_squish,
400 - (copter[0].w), 32,
{
/* Helicopter speeding off: */
- texture_draw_part(&bkgd, 0, 32, screen->w, (copter_stretch.h), NO_UPDATE);
+ texture_draw_part(&bkgd, 0, 32, 0, 32, screen->w, (copter_stretch.h), NO_UPDATE);
texture_draw(&copter_stretch,
(timer_get_gone(&timer) - 8250) /*(i - (8250 / FPS)) * 30*/ + 400 - (copter[0].w),