add some dust effect to rolling/sliding hedgehogs
authorsheepluva
Wed, 13 Jan 2016 16:19:50 +0100
changeset 11511 24bef86e3f3a
parent 11510 32bad5758df6
child 11512 bd9a2f1b0080
add some dust effect to rolling/sliding hedgehogs
hedgewars/uGearsRender.pas
--- a/hedgewars/uGearsRender.pas	Tue Jan 12 17:18:51 2016 -0500
+++ b/hedgewars/uGearsRender.pas	Wed Jan 13 16:19:50 2016 +0100
@@ -846,6 +846,7 @@
 
     end else // not gstHHDriven
         begin
+        // check if hedgehog is sliding/rolling
         if (Gear^.Damage > 0) and (HH^.Effects[heFrozen] = 0)
         and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
             begin
@@ -855,6 +856,23 @@
                     2,
                     1,
                     Gear^.DirAngle);
+
+            // dust effect
+            // TODO fix: this gives different results based on framerate
+            if (sx mod 8) = 0 then
+                begin
+                if Gear^.dX.isNegative then
+                    tx := hwRound(Gear^.X) + cHHRadius
+                else
+                    tx := hwRound(Gear^.X) - cHHRadius;
+                ty:= hwRound(Gear^.Y) + cHHRadius + 2;
+                if ((tx and LAND_WIDTH_MASK) = 0) and
+                    ((ty and LAND_HEIGHT_MASK) = 0) and
+                        (Land[ty, tx] <> 0) then
+                            AddVisualGear(tx - 2 + Random(4), ty - 8, vgtDust);
+                end;
+
+            // draw april's fool hat
             if AprilOne and (curhat <> nil) then
                 DrawTextureRotatedF(curhat, 1.0, -1.0, 0, sx, sy, 18, sign, 32, 32,
                     sign*Gear^.DirAngle)