Birdy appears from off-screen
authorpalewolf
Sun, 28 Mar 2010 23:37:28 +0000
changeset 3149 08c4d9670b54
parent 3148 3e28a12be5ac
child 3150 d212e612c08e
Birdy appears from off-screen
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uGears.pas
--- a/hedgewars/GSHandlers.inc	Sun Mar 28 23:21:07 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Sun Mar 28 23:37:28 2010 +0000
@@ -2781,16 +2781,17 @@
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
-procedure doStepBirdyVanish(Gear: PGear);
+procedure doStepBirdyDisappear(Gear: PGear);
 begin
+AllInactive:= false;
 Gear^.Pos:= 0;
-if Gear^.Timer < 500 then
+if Gear^.Timer < 2000 then
     inc(Gear^.Timer, 1)
 else
     begin
     DeleteGear(Gear);
-    AfterAttack
-    end
+    AfterAttack;
+    end;
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -2873,7 +2874,23 @@
         Active:= true;
         State:= State or gstMoving
         end;
-    Gear^.doStep:= @doStepBirdyVanish;
+    if Gear^.Tag = -1 then
+        begin
+        Gear^.dX:= Gear^.X + int2hwFloat(LAND_WIDTH + 1024);
+        Gear^.dY:= int2hwFloat(256);
+        Gear^.X:= int2hwFloat(-LAND_WIDTH -1024);
+        Gear^.Y:= Gear^.Y + int2hwFloat(-256);
+        end
+    else
+        begin
+        Gear^.dX:= Gear^.X - int2hwFloat(LAND_WIDTH + 1024);
+        Gear^.dY:= int2hwFloat(256);
+        Gear^.X:= int2hwFloat(+LAND_WIDTH +1024);
+        Gear^.Y:= Gear^.Y + int2hwFloat(-256);
+        end;
+    Gear^.State:= Gear^.State or gstAnimation or gstTmpFlag;
+    Gear^.Timer:= 0;
+    Gear^.doStep:= @doStepBirdyDisappear;
     isCursorVisible:= false;
     end
 end;
@@ -2887,7 +2904,7 @@
     dec(Gear^.Timer, 1)
 else if CurrentHedgehog = nil then
     begin
-    Gear^.doStep:= @doStepBirdyVanish;
+    DeleteGear(Gear);
     exit
     end;
 HHGear:= CurrentHedgehog^.Gear;
@@ -2904,11 +2921,27 @@
     end
 end;
 
+procedure doStepBirdyAppear(Gear: PGear);
+begin
+Gear^.Pos:= 0;
+if Gear^.Timer < 2000 then
+    inc(Gear^.Timer, 1)
+else
+    begin
+    Gear^.Timer:= 500;
+    Gear^.dX:= _0;
+    Gear^.dY:= _0;
+    Gear^.State:=  Gear^.State and not gstAnimation;
+    Gear^.doStep:= @doStepBirdyDescend;
+    end
+end;
+
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepBirdy(Gear: PGear);
 var HHGear: PGear;
 begin
-Gear^.doStep:= @doStepBirdyDescend;
+gear^.State:=  gear^.State or gstAnimation and not gstTmpFlag;
+Gear^.doStep:= @doStepBirdyAppear;
 if CurrentHedgehog = nil then
     begin
     DeleteGear(Gear);
--- a/hedgewars/HHHandlers.inc	Sun Mar 28 23:21:07 2010 +0000
+++ b/hedgewars/HHHandlers.inc	Sun Mar 28 23:37:28 2010 +0000
@@ -194,7 +194,16 @@
                     amJetpack: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtJetpack, 0, _0, _0, 0);
                     amBirdy: begin
                              PlaySound(sndWhistle);
-                             CurAmmoGear:= AddGear(hwRound(X), hwRound(Y) - 120, gtBirdy, 0, _0, _0, 0)
+                             if Gear^.dX.isNegative then
+                                begin
+                                CurAmmoGear:= AddGear(hwRound(X), hwRound(Y) - 32, gtBirdy, 0,  int2hwFloat(LAND_WIDTH + 1024 - hwRound(X)), int2hwFloat(-256), 0);
+                                CurAmmoGear^.Tag:= -1;
+                                end
+                             else
+                                begin
+                                CurAmmoGear:= AddGear(hwRound(X), hwRound(Y) - 32, gtBirdy, 0, int2hwFloat(-LAND_WIDTH - 1024 + hwRound(X)), int2hwFloat(-256), 0);
+                                CurAmmoGear^.Tag:= 1;
+                                end;
                              end;
                       amLowGravity: begin
                                     PlaySound(sndLowGravity);
--- a/hedgewars/uGears.pas	Sun Mar 28 23:21:07 2010 +0000
+++ b/hedgewars/uGears.pas	Sun Mar 28 23:37:28 2010 +0000
@@ -457,7 +457,7 @@
                 end;
        gtBirdy: begin
                 gear^.Radius:= 16; // todo: check
-                gear^.Timer:= 500;
+                gear^.Timer:= 0;
                 gear^.Health := 2000;
                 gear^.FlightTime := 2;
                 end;
@@ -1713,7 +1713,17 @@
       gtMelonPiece: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 1, 0, Gear^.DirAngle);
      gtHellishBomb: DrawRotated(sprHellishBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
       gtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
-           gtBirdy: DrawTextureF(SpritesData[sprBirdy].Texture, 1 - Gear^.Timer / 500, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
+           gtBirdy: begin
+                    if Gear^.State and gstAnimation = gstAnimation then
+                        begin
+                        if Gear^.State and gstTmpFlag = 0 then // Appearing
+                            DrawTextureF(SpritesData[sprBirdy].Texture, 1, hwRound(Gear^.X) + WorldDx + hwRound(Gear^.dX) - trunc(hwRound(Gear^.dX) * (-power(2, -10 * LongInt(Gear^.Timer)/2000) + 1)), hwRound(Gear^.Y) + WorldDy + hwRound(Gear^.dY) - trunc(hwRound(Gear^.dY) * sqrt(1 - power((LongInt(Gear^.Timer)/2000)-1, 2))), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75)
+                        else // Disappearing
+                            DrawTextureF(SpritesData[sprBirdy].Texture, 1, hwRound(Gear^.X) + WorldDx + hwRound(Gear^.dX) - trunc(hwRound(Gear^.dX) * power(2, 10 * (LongInt(Gear^.Timer)/2000 - 1))), hwRound(Gear^.Y) + WorldDy + hwRound(Gear^.dY) - trunc(-hwRound(Gear^.dY) * cos(LongInt(Gear^.Timer)/2000 * (Pi/2)) + hwRound(Gear^.dY)), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
+                        end
+                    else
+                        DrawTextureF(SpritesData[sprBirdy].Texture, 1, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
+                    end;
     gtBigExplosion: begin
                     glColor4f(1, 1, 1, 1.0 * (power(2, -5 * (Gear^.Timer-200)/200)));
                     DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -4 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);