More fiddling w/ sliding icegun
authornemo
Mon, 25 Feb 2013 12:29:39 -0500 (2013-02-25)
branchicegun
changeset 8574 684169401a2f
parent 8572 4bd0098aaea7
child 8576 286ebfcb3d97
More fiddling w/ sliding
hedgewars/GSHandlers.inc
hedgewars/uGears.pas
hedgewars/uGearsHedgehog.pas
--- a/hedgewars/GSHandlers.inc	Mon Feb 25 11:35:24 2013 -0500
+++ b/hedgewars/GSHandlers.inc	Mon Feb 25 12:29:39 2013 -0500
@@ -5090,19 +5090,19 @@
 end;
 
 
-function isLanscapeEdge(weight:Longint):boolean;
+function isLandscapeEdge(weight:Longint):boolean;
 begin
     result := (weight < 8) and (weight >= 2);
 end;
 
-function isLanscape(weight:Longint):boolean;
+function isLandscape(weight:Longint):boolean;
 begin
     result := weight < 2;
 end;
 
 function isEmptySpace(weight:Longint):boolean;
 begin
-    result := not isLanscape(weight) and not isLanscapeEdge(weight);
+    result := not isLandscape(weight) and not isLandscapeEdge(weight);
 end;
 
 
@@ -5142,7 +5142,8 @@
     w:= LandPixels[y, x];
     w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED +
           (w shr BShift and $FF) * RGB_LUMINANCE_GREEN +
-          (w shr GShift and $FF) * RGB_LUMINANCE_BLUE)) * 4;
+          (w shr GShift and $FF) * RGB_LUMINANCE_BLUE));
+    if w < 128 then w:= w+128;
     if w > 255 then w:= 255;
     w:= (w shl RShift) or (w shl BShift) or (w shl GShift) or (LandPixels[y,x] and AMask);
     //LandPixels[y, x]:= w;
@@ -5160,23 +5161,25 @@
 begin    
 
     for i := max(x - iceHalfSize, 0) to min(x + iceHalfSize, LAND_WIDTH-1) do
-    begin
+        begin
         for j := max(y - iceHalfSize, 0) to min(y + iceHalfSize, LAND_HEIGHT-1) do 
-        begin
+            begin
             weight := getPixelWeight(i, j);
-            if isLanscape(weight) then
+            if isLandscape(weight) then
                 begin
                 if Land[j,i] and lfIce = 0 then drawIcePixel(i, j);
-                end else
-            begin
-                if isLanscapeEdge(weight) then 
+                end 
+            else
                 begin
+                if isLandscapeEdge(weight) then 
+                    begin
                     LandPixels[j, i] := $FFB2AF8A;                    
                     if Land[j, i] > 255 then Land[j, i] := Land[j, i] or lfIce;
-                end;                
+                    end;                
+                end;
             end;
         end;
-    end;
+    SetAllHHToActive; 
     UpdateLandTexture(x - iceHalfSize, iceSize, y - iceHalfSize, iceSize, true);
 end;
 
--- a/hedgewars/uGears.pas	Mon Feb 25 11:35:24 2013 -0500
+++ b/hedgewars/uGears.pas	Mon Feb 25 12:29:39 2013 -0500
@@ -569,7 +569,10 @@
 while t <> nil do
     begin
     if (t^.Kind = gtHedgehog) or (t^.Kind = gtExplosives) then
-        t^.Active:= true;
+        begin
+        if t^.Kind = gtHedgehog then CheckIce(t);
+        t^.Active:= true
+        end;
     t:= t^.NextGear
     end
 end;
--- a/hedgewars/uGearsHedgehog.pas	Mon Feb 25 11:35:24 2013 -0500
+++ b/hedgewars/uGearsHedgehog.pas	Mon Feb 25 12:29:39 2013 -0500
@@ -29,6 +29,7 @@
 procedure HedgehogChAngle(HHGear: PGear); 
 procedure PickUp(HH, Gear: PGear);
 procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord);
+procedure CheckIce(Gear: PGear); inline;
 
 implementation
 uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, 
@@ -1213,20 +1214,50 @@
 AllInactive:= false
 end;
 
-////////////////////////////////////////////////////////////////////////////////
-procedure doStepHedgehog(Gear: PGear);
+procedure CheckIce(Gear: PGear); inline;
 (*
 var x,y,tx,ty: LongInt;
     tdX, tdY, slope: hwFloat; 
     land: Word; *)
 var slope: hwFloat; 
 begin
+    if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0)
+    and (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0)
+    and (not Gear^.dY.isNegative) and (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then
+        begin
+        slope:= CalcSlopeBelowGear(Gear);
+        if slope.QWordValue > 730144440 then // ignore mild slopes
+            begin
+            Gear^.dX:=Gear^.dX+slope*cGravity*_256;
+            Gear^.State:= Gear^.State or gstMoving
+            end
+        end;
+(*
+    x:= hwRound(Gear^.X);
+    y:= hwRound(Gear^.Y);
+    AddVisualGear(x, y, vgtSmokeTrace);
+    AddVisualGear(x - hwRound(_5*slope), y + hwRound(_5*slope), vgtSmokeTrace);
+    AddVisualGear(x + hwRound(_5*slope), y - hwRound(_5*slope), vgtSmokeTrace);
+    AddVisualGear(x - hwRound(_20 * slope), y + hwRound(_20 * slope), vgtSmokeTrace);
+    AddVisualGear(x + hwRound(_20 * slope), y - hwRound(_20 * slope), vgtSmokeTrace);
+    AddVisualGear(x - hwRound(_30 * slope), y + hwRound(_30 * slope), vgtSmokeTrace);
+    AddVisualGear(x + hwRound(_30 * slope), y - hwRound(_30 * slope), vgtSmokeTrace);
+    AddVisualGear(x - hwRound(_40 * slope), y + hwRound(_40 * slope), vgtSmokeTrace);
+    AddVisualGear(x + hwRound(_40 * slope), y - hwRound(_40 * slope), vgtSmokeTrace);
+    AddVisualGear(x - hwRound(_50 * slope), y + hwRound(_50 * slope), vgtSmokeTrace);
+    AddVisualGear(x + hwRound(_50 * slope), y - hwRound(_50 * slope), vgtSmokeTrace); *)
+end;
+
+////////////////////////////////////////////////////////////////////////////////
+procedure doStepHedgehog(Gear: PGear);
+begin
 CheckSum:= CheckSum xor Gear^.Hedgehog^.BotLevel;
 if (Gear^.Message and gmDestroy) <> 0 then
     begin
     DeleteGear(Gear);
     exit
     end;
+if (GameTicks mod (100*LongWord(hwRound(cMaxWindSpeed*2/cGravity))) = 0) then CheckIce(Gear);
 if Gear^.Hedgehog^.Effects[heFrozen] > 0 then 
     begin
     if Gear^.Hedgehog^.Effects[heFrozen] > 256 then
@@ -1244,30 +1275,6 @@
         else
             doStepHedgehogDriven(Gear)
     end;
-if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0)
-and (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0)
-and (not Gear^.dY.isNegative) and (GameTicks mod (100*LongWOrd(hwRound(cMaxWindSpeed*2/cGravity))) = 0)
-and (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then
-    begin
-    slope:= CalcSlopeBelowGear(Gear);
-    Gear^.dX:=Gear^.dX+slope*_0_07;
-    if slope.QWordValue <> 0 then
-        Gear^.State:= Gear^.State or gstMoving;
-(*
-    x:= hwRound(Gear^.X);
-    y:= hwRound(Gear^.Y);
-    AddVisualGear(x, y, vgtSmokeTrace);
-    AddVisualGear(x - hwRound(_5*slope), y + hwRound(_5*slope), vgtSmokeTrace);
-    AddVisualGear(x + hwRound(_5*slope), y - hwRound(_5*slope), vgtSmokeTrace);
-    AddVisualGear(x - hwRound(_20 * slope), y + hwRound(_20 * slope), vgtSmokeTrace);
-    AddVisualGear(x + hwRound(_20 * slope), y - hwRound(_20 * slope), vgtSmokeTrace);
-    AddVisualGear(x - hwRound(_30 * slope), y + hwRound(_30 * slope), vgtSmokeTrace);
-    AddVisualGear(x + hwRound(_30 * slope), y - hwRound(_30 * slope), vgtSmokeTrace);
-    AddVisualGear(x - hwRound(_40 * slope), y + hwRound(_40 * slope), vgtSmokeTrace);
-    AddVisualGear(x + hwRound(_40 * slope), y - hwRound(_40 * slope), vgtSmokeTrace);
-    AddVisualGear(x - hwRound(_50 * slope), y + hwRound(_50 * slope), vgtSmokeTrace);
-    AddVisualGear(x + hwRound(_50 * slope), y - hwRound(_50 * slope), vgtSmokeTrace); *)
-    end
 end;
 
 end.