--- 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;