871 inc(HHGear^.Angle, da) |
871 inc(HHGear^.Angle, da) |
872 end; |
872 end; |
873 |
873 |
874 |
874 |
875 //////////////////////////////////////////////////////////////////////////////// |
875 //////////////////////////////////////////////////////////////////////////////// |
|
876 procedure moveHedgehogOutOfWall(Gear: PGear); |
|
877 var |
|
878 hx: hwFloat; |
|
879 colly, collxl, collxr: boolean; |
|
880 begin |
|
881 colly:= (TestCollisionYwithGear(Gear, 1) <> 0); |
|
882 |
|
883 while colly do |
|
884 begin |
|
885 // don't use TestCollisionXwithXYShift, because we don't gears |
|
886 // save real x-position |
|
887 hx:= Gear^.X; |
|
888 |
|
889 Gear^.X:= hx + _1; |
|
890 collxl:= (TestCollisionX(Gear, -1) <> 0); |
|
891 |
|
892 Gear^.X:= hx - _1; |
|
893 collxr:= (TestCollisionX(Gear, 1) <> 0); |
|
894 |
|
895 // restore original value |
|
896 Gear^.X:= hx; |
|
897 |
|
898 // do nothing if trapped between 2 walls |
|
899 if collxl = collxr then |
|
900 break; |
|
901 |
|
902 // if we in a wall - fix that |
|
903 if collxl then |
|
904 begin |
|
905 // check for obstacle |
|
906 if (TestCollisionX(Gear, 1) <> 0) then |
|
907 break; |
|
908 Gear^.X:= Gear^.X + _1; |
|
909 end |
|
910 else |
|
911 begin |
|
912 // check for obstacle |
|
913 if (TestCollisionX(Gear, -1) <> 0) then |
|
914 break; |
|
915 Gear^.X:= Gear^.X - _1; |
|
916 end; |
|
917 |
|
918 colly:= (TestCollisionYwithGear(Gear, 1) <> 0); |
|
919 end; |
|
920 |
|
921 |
|
922 end; |
|
923 |
|
924 //////////////////////////////////////////////////////////////////////////////// |
876 procedure doStepHedgehogMoving(Gear: PGear); |
925 procedure doStepHedgehogMoving(Gear: PGear); |
877 var isFalling, isUnderwater: boolean; |
926 var isFalling, isUnderwater: boolean; |
878 land: Word; |
927 land: Word; |
879 cnt: LongWord; |
928 cnt: LongWord; |
880 begin |
929 begin |
891 if Gear^.dX.QWordValue > 8160437862 then |
940 if Gear^.dX.QWordValue > 8160437862 then |
892 Gear^.dX.QWordValue:= 8160437862; |
941 Gear^.dX.QWordValue:= 8160437862; |
893 if Gear^.dY.QWordValue > 8160437862 then |
942 if Gear^.dY.QWordValue > 8160437862 then |
894 Gear^.dY.QWordValue:= 8160437862; |
943 Gear^.dY.QWordValue:= 8160437862; |
895 |
944 |
896 isFalling:= (Gear^.dY.isNegative) or (TestCollisionYKick(Gear, 1) = 0); |
945 isFalling:= (Gear^.dY.isNegative); |
|
946 if (not isFalling) then |
|
947 begin |
|
948 // make sure we're not just stuck in wall |
|
949 moveHedgehogOutOfWall(Gear); |
|
950 // test for floor/obstacle below |
|
951 isFalling:= (TestCollisionYKick(Gear, 1) = 0); |
|
952 end; |
|
953 |
897 if isFalling then |
954 if isFalling then |
898 begin |
955 begin |
899 land:= TestCollisionYKick(Gear, -1); |
956 land:= TestCollisionYKick(Gear, -1); |
900 if (Gear^.dY.isNegative) and (land <> 0) then |
957 if (Gear^.dY.isNegative) and (land <> 0) then |
901 begin |
958 begin |