- Add HH dX/dY to Birdy disappearing animation
authorpalewolf
Mon, 29 Mar 2010 20:32:35 +0000
changeset 3161 cb5f04cc9d76
parent 3160 f2a3d861b23a
child 3162 663e0e55e5c7
- Add HH dX/dY to Birdy disappearing animation - Feather amount is proportional fo fuel left
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uGears.pas
--- a/hedgewars/GSHandlers.inc	Mon Mar 29 20:27:54 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Mon Mar 29 20:32:35 2010 +0000
@@ -2796,7 +2796,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepBirdyFly(Gear: PGear);
 var HHGear: PGear;
-    fuel: LongInt;
+    fuel, i: LongInt;
     move: hwFloat;
 begin
 HHGear:= CurrentHedgehog^.Gear;
@@ -2831,10 +2831,11 @@
     end;
 
 if Gear^.Health < 0 then Gear^.Health:= 0;
-if (GameTicks and $3F) = 0 then
+if (GameTicks and $7F) = 0 then
        begin
-       if Gear^.Health < 500 then
-         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFeather);
+       if Gear^.Health < 1000 then
+            for i:= ((1000-Gear^.Health) div 250) downto 0 do
+                AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFeather);
        if Gear^.Tex <> nil then FreeTexture(Gear^.Tex);
        Gear^.Tex:= RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(round(Gear^.Health / 20)) + '%', cWhiteColor, fntSmall)
        end;
@@ -2873,21 +2874,12 @@
         Active:= true;
         State:= State or gstMoving
         end;
-    if Gear^.Tag = -1 then
+    Gear^.State:= Gear^.State or gstAnimation or gstTmpFlag;
+    if HHGear^.dY < _0 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);
+        Gear^.dX:= HHGear^.dX;
+        Gear^.dY:= HHGear^.dY;
         end;
-    Gear^.State:= Gear^.State or gstAnimation or gstTmpFlag;
     Gear^.Timer:= 0;
     Gear^.doStep:= @doStepBirdyDisappear;
     CurAmmoGear:= nil;
--- a/hedgewars/HHHandlers.inc	Mon Mar 29 20:27:54 2010 +0000
+++ b/hedgewars/HHHandlers.inc	Mon Mar 29 20:32:35 2010 +0000
@@ -194,16 +194,7 @@
                     amJetpack: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtJetpack, 0, _0, _0, 0);
                     amBirdy: begin
                              PlaySound(sndWhistle);
-                             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;
+                             CurAmmoGear:= AddGear(hwRound(X), hwRound(Y) - 32, gtBirdy, 0, _0, _0, 0);
                              end;
                       amLowGravity: begin
                                     PlaySound(sndLowGravity);
--- a/hedgewars/uGears.pas	Mon Mar 29 20:27:54 2010 +0000
+++ b/hedgewars/uGears.pas	Mon Mar 29 20:32:35 2010 +0000
@@ -1611,6 +1611,7 @@
 procedure DrawGears;
 var Gear, HHGear: PGear;
     i: Longword;
+    startX, endX, startY, endY: LongInt;
 begin
 Gear:= GearsList;
 while Gear<>nil do
@@ -1717,9 +1718,27 @@
                     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)
+                            begin
+                            endX:= hwRound(Gear^.X);
+                            endY:= hwRound(Gear^.Y);
+                            if Gear^.Tag < 0 then
+                                startX:= max(LAND_WIDTH + 1024, endX + 2048)
+                            else
+                                startX:= max(-LAND_WIDTH - 1024, endX - 2048);
+                            startY:= endY - 256;
+                            DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + trunc((endX - startX) * (-power(2, -10 * LongInt(Gear^.Timer)/2000) + 1)), startY + WorldDy + trunc((endY - startY) * sqrt(1 - power((LongInt(Gear^.Timer)/2000)-1, 2))), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
+                            end
                         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);
+                            begin
+                            startX:= hwRound(Gear^.X);
+                            startY:= hwRound(Gear^.Y);
+                            if Gear^.Tag > 0 then
+                                endX:= max(LAND_WIDTH + 1024, startX + 2048)
+                            else
+                                endX:= max(-LAND_WIDTH - 1024, startX - 2048);
+                            endY:= startY + 256;
+                            DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + trunc((endX - startX) * power(2, 10 * (LongInt(Gear^.Timer)/2000 - 1))) + hwRound(Gear^.dX * Gear^.Timer), startY + WorldDy + trunc((endY - startY) * cos(LongInt(Gear^.Timer)/2000 * (Pi/2)) - (endY - startY)) + hwRound(Gear^.dY * Gear^.Timer), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
+                            end;
                         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);