ugly but working fix for the beam bug.
[supertux.git] / src / intro.c
index 0efb9b5..fffdaf7 100644 (file)
@@ -2,7 +2,7 @@
   intro.c
   
   Super Tux - Intro Screen
-  
+
   by Bill Kendrick
   bill@newbreedsoftware.com
   http://www.newbreedsoftware.com/supertux/
@@ -70,8 +70,8 @@ int intro(void)
   
   /* 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: */
@@ -137,7 +137,7 @@ int intro(void)
          texture_draw(&tux_sit, 270, 400, UPDATE);
          texture_draw(&gown_sit, 320, 400, UPDATE);
          
-         text_drawf(&blue_text, intro_text[0], 0, -8, A_HMIDDLE, A_BOTTOM, 0, NO_UPDATE);
+         text_drawf(&white_text, intro_text[0], 0, -8, A_HMIDDLE, A_BOTTOM, 0, NO_UPDATE);
        }
       
       
@@ -146,8 +146,8 @@ int intro(void)
          ++scene;
          /* Helicopter begins to fly in: */
          
-         erasecenteredtext(intro_text[0], 456, &bkgd, NO_UPDATE, 1);
-         text_drawf(&blue_text, intro_text[1], 0,-8, A_HMIDDLE, A_BOTTOM, 0, NO_UPDATE);
+         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);
        }
 
       
@@ -200,20 +200,20 @@ int intro(void)
          texture_draw(&tux_upset, 270, 400, UPDATE);
          
          
-         erasecenteredtext(intro_text[1], 456, &bkgd, UPDATE, 1);
-         text_drawf(&blue_text, intro_text[2], 0,-8, A_HMIDDLE, A_BOTTOM, 0, NO_UPDATE);
+         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, 32 + (copter[0].h), 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++)
@@ -233,29 +233,36 @@ int intro(void)
              
              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, UPDATE, 1);
-         text_drawf(&blue_text, intro_text[3], 0,-8, A_HMIDDLE, A_BOTTOM, 0, NO_UPDATE);
+         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);
        }