815 Gear^.dY:= _0; |
816 Gear^.dY:= _0; |
816 end else Gear^.dY:= Gear^.dY + cGravity; |
817 end else Gear^.dY:= Gear^.dY + cGravity; |
817 |
818 |
818 if ((Gear^.State and gstMoving) <> 0) then |
819 if ((Gear^.State and gstMoving) <> 0) then |
819 begin |
820 begin |
820 if land and lfIce <> 0 then Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2) |
821 if land and lfIce <> 0 then |
|
822 begin |
|
823 Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2) |
|
824 end |
821 else Gear^.dX:= Gear^.dX * Gear^.Friction; |
825 else Gear^.dX:= Gear^.dX * Gear^.Friction; |
822 end |
826 end |
823 end; |
827 end; |
824 |
828 |
825 if (Gear^.State <> 0) then DeleteCI(Gear); |
829 if (Gear^.State <> 0) then DeleteCI(Gear); |
840 if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_87; Gear^.Y:= Gear^.Y - _4 end else |
844 if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_87; Gear^.Y:= Gear^.Y - _4 end else |
841 if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_84; Gear^.Y:= Gear^.Y - _5 end else |
845 if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_84; Gear^.Y:= Gear^.Y - _5 end else |
842 if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
846 if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
843 else begin |
847 else begin |
844 Gear^.State:= Gear^.State and not gstMoving; |
848 Gear^.State:= Gear^.State and not gstMoving; |
|
849 while TestCollisionYWithGear(Gear,1) = 0 do Gear^.Y:= Gear^.Y+_1; |
845 SetLittle(Gear^.dX) |
850 SetLittle(Gear^.dX) |
846 end |
851 end |
847 else begin |
852 else begin |
848 Gear^.State:= Gear^.State and not gstMoving; |
853 Gear^.State:= Gear^.State and not gstMoving; |
|
854 while TestCollisionYWithGear(Gear,1) = 0 do Gear^.Y:= Gear^.Y+_1; |
849 SetLittle(Gear^.dX) |
855 SetLittle(Gear^.dX) |
850 end |
856 end |
851 else if (hwAbs(Gear^.dX) > cLittle) |
857 else if (hwAbs(Gear^.dX) > cLittle) |
852 and ((Gear^.State and gstHHJumping) = 0) |
858 and ((Gear^.State and gstHHJumping) = 0) |
853 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
859 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
856 if (not isFalling) and |
862 if (not isFalling) and |
857 (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
863 (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
858 begin |
864 begin |
859 Gear^.State:= Gear^.State and not gstWinner; |
865 Gear^.State:= Gear^.State and not gstWinner; |
860 Gear^.State:= Gear^.State and not gstMoving; |
866 Gear^.State:= Gear^.State and not gstMoving; |
|
867 while TestCollisionYWithGear(Gear,1) = 0 do Gear^.Y:= Gear^.Y+_1; |
861 SetLittle(Gear^.dX); |
868 SetLittle(Gear^.dX); |
862 Gear^.dY:= _0 |
869 Gear^.dY:= _0 |
863 end else Gear^.State:= Gear^.State or gstMoving; |
870 end else Gear^.State:= Gear^.State or gstMoving; |
864 |
871 |
865 if (Gear^.State and gstMoving) <> 0 then |
872 if (Gear^.State and gstMoving) <> 0 then |
1100 |
1107 |
1101 //////////////////////////////////////////////////////////////////////////////// |
1108 //////////////////////////////////////////////////////////////////////////////// |
1102 procedure doStepHedgehog(Gear: PGear); |
1109 procedure doStepHedgehog(Gear: PGear); |
1103 (* |
1110 (* |
1104 var x,y,tx,ty: LongInt; |
1111 var x,y,tx,ty: LongInt; |
1105 tdX, tdY, slope: hwFloat; *) |
1112 tdX, tdY, slope: hwFloat; |
|
1113 land: Word; *) |
|
1114 var slope: hwFloat; |
1106 begin |
1115 begin |
1107 if (Gear^.Message and gmDestroy) <> 0 then |
1116 if (Gear^.Message and gmDestroy) <> 0 then |
1108 begin |
1117 begin |
1109 DeleteGear(Gear); |
1118 DeleteGear(Gear); |
1110 exit |
1119 exit |
1119 TeamGoneEffect(Team^) |
1128 TeamGoneEffect(Team^) |
1120 else |
1129 else |
1121 doStepHedgehogDriven(Gear) |
1130 doStepHedgehogDriven(Gear) |
1122 end; |
1131 end; |
1123 |
1132 |
1124 if ((GameTicks mod 50) = 0) and (Gear^.State and (gstMoving or gstHHJumping or gstHHHJump) = 0) and ((Gear^.Message and gmAllStoppable) = 0) and |
1133 if ((GameTicks mod 50) = 0) and (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) and |
1125 (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then |
1134 (Gear^.State and (gstHHJumping or gstHHHJump) = 0) and |
1126 begin |
1135 not Gear^.dY.isNegative and |
1127 if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y)+cHHRadius, lfIce) then |
1136 (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then |
1128 begin |
1137 begin |
1129 Gear^.dX.QWordValue:= Gear^.dX.QWordValue + cGravity.QWordValue * 75; |
1138 slope:= CalcSlopeBelowGear(Gear); |
1130 Gear^.State:= Gear^.State or gstMoving; |
1139 Gear^.dX:=Gear^.dX+cGravity*_128*slope; |
1131 end |
1140 Gear^.State:= Gear^.State or gstMoving; |
1132 (* |
1141 (* |
1133 // check land slope, and impart a dX based on it |
1142 x:= hwRound(Gear^.X); |
1134 tdX:= Gear^.dX; |
1143 y:= hwRound(Gear^.Y); |
1135 tdY:= Gear^.dY; |
1144 AddVisualGear(x, y, vgtSmokeTrace); |
1136 Gear^.dX:= _0; |
1145 AddVisualGear(x - hwRound(_5*slope), y + hwRound(_5*slope), vgtSmokeTrace); |
1137 Gear^.dY:= _1; |
1146 AddVisualGear(x + hwRound(_5*slope), y - hwRound(_5*slope), vgtSmokeTrace); |
1138 x := hwRound(Gear^.X); |
1147 AddVisualGear(x - hwRound(_20 * slope), y + hwRound(_20 * slope), vgtSmokeTrace); |
1139 y := hwRound(Gear^.Y); |
1148 AddVisualGear(x + hwRound(_20 * slope), y - hwRound(_20 * slope), vgtSmokeTrace); |
1140 tx := 0; |
1149 AddVisualGear(x - hwRound(_30 * slope), y + hwRound(_30 * slope), vgtSmokeTrace); |
1141 ty := 0; |
1150 AddVisualGear(x + hwRound(_30 * slope), y - hwRound(_30 * slope), vgtSmokeTrace); |
1142 if not CalcSlopeTangent(Gear, x, y+cHHRadius, tx, ty, 255) then |
1151 AddVisualGear(x - hwRound(_40 * slope), y + hwRound(_40 * slope), vgtSmokeTrace); |
1143 begin |
1152 AddVisualGear(x + hwRound(_40 * slope), y - hwRound(_40 * slope), vgtSmokeTrace); |
1144 slope:= _1/DistanceI(tx,ty); |
1153 AddVisualGear(x - hwRound(_50 * slope), y + hwRound(_50 * slope), vgtSmokeTrace); |
1145 AddFileLog(FloatToStr(tdX)+ ' == '+FloatToStr(slope)); |
1154 AddVisualGear(x + hwRound(_50 * slope), y - hwRound(_50 * slope), vgtSmokeTrace); *) |
1146 tdX:= tdX + (cGravity * slope / _10) // this will need tuning |
1155 end |
1147 end; |
1156 end; |
1148 Gear^.dX:= tdX; |
|
1149 Gear^.dY:= tdY *) |
|
1150 end; |
|
1151 end; |
|