A bit less WTF of ice, ice chutes now work. Also tweak flake respawn positions a bit
authornemo
Sat, 05 Nov 2011 17:24:09 -0400
changeset 6291 cfd2483b8c97
parent 6290 c6245ed6cbc0
child 6292 891bf597e2dc
A bit less WTF of ice, ice chutes now work. Also tweak flake respawn positions a bit
hedgewars/HHHandlers.inc
hedgewars/VGSHandlers.inc
hedgewars/uVisualGears.pas
--- a/hedgewars/HHHandlers.inc	Sat Nov 05 20:43:20 2011 +0300
+++ b/hedgewars/HHHandlers.inc	Sat Nov 05 17:24:09 2011 -0400
@@ -772,6 +772,7 @@
    Gear^.dY:= _0;
    Gear^.dX:= _0;
    Gear^.State:= Gear^.State and not gstMoving;
+   while TestCollisionYWithGear(Gear,1) = 0 do Gear^.Y:= Gear^.Y+_1;
    exit
    end;
 isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1);
@@ -817,7 +818,10 @@
 
    if ((Gear^.State and gstMoving) <> 0) then
        begin
-       if land and lfIce <> 0 then Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2)
+       if land and lfIce <> 0 then
+           begin
+           Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2)
+           end
        else Gear^.dX:= Gear^.dX * Gear^.Friction;
        end
    end;
@@ -842,10 +846,12 @@
             if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX
                                    else begin
                                         Gear^.State:= Gear^.State and not gstMoving;
+                                        while TestCollisionYWithGear(Gear,1) = 0 do Gear^.Y:= Gear^.Y+_1;
                                         SetLittle(Gear^.dX)
                                         end
             else begin
                  Gear^.State:= Gear^.State and not gstMoving;
+                 while TestCollisionYWithGear(Gear,1) = 0 do Gear^.Y:= Gear^.Y+_1;
                  SetLittle(Gear^.dX)
                  end
          else if (hwAbs(Gear^.dX) > cLittle)
@@ -858,6 +864,7 @@
    begin
    Gear^.State:= Gear^.State and not gstWinner;
    Gear^.State:= Gear^.State and not gstMoving;
+   while TestCollisionYWithGear(Gear,1) = 0 do Gear^.Y:= Gear^.Y+_1;
    SetLittle(Gear^.dX);
    Gear^.dY:= _0
    end else Gear^.State:= Gear^.State or gstMoving;
@@ -1102,7 +1109,9 @@
 procedure doStepHedgehog(Gear: PGear);
 (*
 var x,y,tx,ty: LongInt;
-    tdX, tdY, slope: hwFloat; *)
+    tdX, tdY, slope: hwFloat; 
+    land: Word; *)
+var slope: hwFloat; 
 begin
 if (Gear^.Message and gmDestroy) <> 0 then
     begin
@@ -1121,31 +1130,27 @@
             doStepHedgehogDriven(Gear)
     end;
 
-if ((GameTicks mod 50) = 0) and (Gear^.State and (gstMoving or gstHHJumping or gstHHHJump) = 0) and ((Gear^.Message and gmAllStoppable) = 0) and 
-    (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then
+if ((GameTicks mod 50) = 0) and (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) and
+   (Gear^.State and (gstHHJumping or gstHHHJump) = 0) and
+   not Gear^.dY.isNegative and
+   (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then
     begin
-    if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y)+cHHRadius, lfIce) then
-        begin
-        Gear^.dX.QWordValue:= Gear^.dX.QWordValue + cGravity.QWordValue * 75;
-        Gear^.State:= Gear^.State or gstMoving;
-        end
+    slope:= CalcSlopeBelowGear(Gear);
+    Gear^.dX:=Gear^.dX+cGravity*_128*slope;
+    Gear^.State:= Gear^.State or gstMoving;
 (*
-    // check land slope, and impart a dX based on it
-    tdX:= Gear^.dX;
-    tdY:= Gear^.dY;
-    Gear^.dX:= _0;
-    Gear^.dY:= _1;
-    x := hwRound(Gear^.X);
-    y := hwRound(Gear^.Y);
-    tx := 0;
-    ty := 0;
-    if not CalcSlopeTangent(Gear, x, y+cHHRadius, tx, ty, 255) then
-        begin
-        slope:= _1/DistanceI(tx,ty);
-        AddFileLog(FloatToStr(tdX)+ ' == '+FloatToStr(slope));
-        tdX:= tdX + (cGravity * slope / _10)  // this will need tuning 
-        end;
-    Gear^.dX:= tdX;
-    Gear^.dY:= tdY  *)
-    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
 end;
--- a/hedgewars/VGSHandlers.inc	Sat Nov 05 20:43:20 2011 +0300
+++ b/hedgewars/VGSHandlers.inc	Sat Nov 05 17:24:09 2011 -0400
@@ -79,7 +79,8 @@
         if round(X) < cLeftScreenBorder then X:= X + cScreenSpace else
         if round(X) > cRightScreenBorder then X:= X - cScreenSpace;
         // if round(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + 25.0; // For if flag is set for flakes rising upwards?
-        if round(Y) - 225 > LAND_HEIGHT then Y:= Y - (1024 + 300); // TODO - configure in theme (jellies for example could use limited range)
+        if (Gear^.Layer > 1) and (round(Y) - 225 > LAND_HEIGHT) then Y:= Y - (1024 + 300) // TODO - configure in theme (jellies for example could use limited range)
+        else if (Gear^.Layer < 2) and (round(Y) + 50 > LAND_HEIGHT) then Y:= Y - (1024 + 25);
         Timer:= 0;
         tdX:= 0;
         tdY:= 0
--- a/hedgewars/uVisualGears.pas	Sat Nov 05 20:43:20 2011 +0300
+++ b/hedgewars/uVisualGears.pas	Sat Nov 05 17:24:09 2011 -0400
@@ -338,7 +338,7 @@
 
 case Gear^.Kind of
     vgtFlake: if cFlattenFlakes then gear^.Layer:= 0
-              else if random(3) <> 0 then gear^.Layer:= 0   // 66%
+              else if random(3) <> 0 then gear^.Layer:= 0   // 67%
               else if random(3) <> 0 then gear^.Layer:= 1  // 22%
               else gear^.Layer:= random(2)+2;  // 6% each