hedgewars/HHHandlers.inc
changeset 511 2b5b9e00419d
parent 505 fcba7d7aea0d
child 513 69e06d710d46
--- a/hedgewars/HHHandlers.inc	Mon May 07 21:12:06 2007 +0000
+++ b/hedgewars/HHHandlers.inc	Wed May 09 20:32:41 2007 +0000
@@ -325,8 +325,9 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepHedgehogFree(Gear: PGear);
+var prevState: Longword;
 begin
-//DeleteCI(Gear);
+prevState:= Gear^.State;
 if not TestCollisionYwithGear(Gear, 1) then
    begin
    if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0;
@@ -373,6 +374,7 @@
 
 if (Gear^.State and gstMoving) <> 0 then
    begin
+   Gear^.State:= Gear^.State and not gstAnimation;
    Gear^.X:= Gear^.X + Gear^.dX;
    Gear^.Y:= Gear^.Y + Gear^.dY;
    if (Gear^.dY > _0) and not TestCollisionYwithGear(Gear, 1) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then
@@ -399,11 +401,20 @@
 
 if (not CheckGearDrowning(Gear)) and
    ((Gear^.State and gstMoving) = 0) then
+   if ((Gear^.State and gstAnimation) = 0) and
+      (prevState <> Gear^.State) then
       begin
-      Gear^.State:= 0;
-      Gear^.Active:= false;
-      AddGearCI(Gear);
-      exit
+      Gear^.State:= gstAnimation;
+      Gear^.Timer:= 150
+      end else
+      begin
+      if Gear^.Timer = 0 then
+         begin
+         Gear^.State:= 0;
+         Gear^.Active:= false;
+         AddGearCI(Gear);
+         exit
+         end else dec(Gear^.Timer)
       end
 end;
 
@@ -416,5 +427,5 @@
    exit
    end;
 if (Gear^.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear)
-                                    else doStepHedgehogDriven(Gear)
+                                     else doStepHedgehogDriven(Gear)
 end;