1836 if (Gear^.Tag = 47) or (cWaterLine = 0) then |
1836 if (Gear^.Tag = 47) or (cWaterLine = 0) then |
1837 DeleteGear(Gear) |
1837 DeleteGear(Gear) |
1838 end; |
1838 end; |
1839 |
1839 |
1840 //////////////////////////////////////////////////////////////////////////////// |
1840 //////////////////////////////////////////////////////////////////////////////// |
1841 procedure doStepDiggingGear(Gear: PGear); |
1841 procedure doStepDrillDrilling(Gear: PGear); |
1842 var ox,oy: hwFloat; |
1842 var ox,oy: hwFloat; |
1843 begin |
1843 begin |
|
1844 AllInactive:= false; |
|
1845 |
|
1846 if (Gear^.Timer > 0) and ((Gear^.Timer mod 20) = 0) then |
|
1847 begin |
1844 ox:= Gear^.X; |
1848 ox:= Gear^.X; |
1845 oy:= Gear^.Y; |
1849 oy:= Gear^.Y; |
1846 Gear^.X:= Gear^.X + Gear^.dX; |
1850 Gear^.X:= Gear^.X + Gear^.dX; |
1847 Gear^.Y:= Gear^.Y + Gear^.dY; |
1851 Gear^.Y:= Gear^.Y + Gear^.dY; |
1848 DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6); |
1852 DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6); |
1849 CheckGearDrowning(Gear); |
1853 CheckGearDrowning(Gear); |
|
1854 end; |
|
1855 |
|
1856 if (Gear^.Timer = 0) |
|
1857 or (not TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) |
|
1858 and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) then |
|
1859 begin //out of time or exited ground |
|
1860 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1861 DeleteGear(Gear); |
|
1862 exit |
|
1863 end; |
|
1864 |
|
1865 dec(Gear^.Timer); |
1850 end; |
1866 end; |
1851 |
1867 |
1852 procedure doStepDrill(Gear: PGear); |
1868 procedure doStepDrill(Gear: PGear); |
1853 var newX, newY, oldDx, oldDy: hwFloat; |
1869 var t: PGearArray; |
1854 t: PGearArray; |
1870 newX, newY, oldDx, oldDy: hwFloat; |
1855 begin |
1871 begin |
1856 AllInactive:= false; |
1872 AllInactive:= false; |
1857 |
1873 |
1858 if (Gear^.Timer = 5000) then begin //flying |
1874 Gear^.dX:= Gear^.dX + cWindSpeed; |
1859 Gear^.dX:= Gear^.dX + cWindSpeed; |
1875 oldDx:= Gear^.dX; |
1860 oldDx:= Gear^.dX; |
1876 oldDy:= Gear^.dY; |
1861 oldDy:= Gear^.dY; |
1877 |
1862 doStepFallingGear(Gear); |
1878 doStepFallingGear(Gear); |
1863 if (GameTicks and $3F) = 0 then |
1879 |
1864 AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
1880 if (GameTicks and $3F) = 0 then |
1865 end; |
1881 AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
1866 |
1882 |
1867 if ((Gear^.State and gstCollision) <> 0) and (Gear^.Timer = 5000) then |
1883 if ((Gear^.State and gstCollision) <> 0) then |
1868 begin //hit |
1884 begin //hit |
1869 Gear^.dX:= oldDx; |
1885 Gear^.dX:= oldDx; |
1870 Gear^.dY:= oldDy; |
1886 Gear^.dY:= oldDy; |
1871 t:= CheckGearsCollision(Gear); |
1887 t:= CheckGearsCollision(Gear); |
1872 if (t^.Count = 0) then |
1888 Gear^.doStep:= @doStepDrillDrilling; |
1873 begin //hit the ground not the hedgehog |
1889 if (t^.Count = 0) then |
1874 newy:= hwSqrt((_0_5 * Gear^.dY * Gear^.dY) / Distance(Gear^.dX, Gear^.dY)); |
1890 begin //hit the ground not the hedgehog |
1875 if (Gear^.dY < _0) then newY := -newY; |
1891 newy:= hwSqrt((_0_5 * Gear^.dY * Gear^.dY) / Distance(Gear^.dX, Gear^.dY)); |
1876 newx:= newy * Gear^.dX / Gear^.dY; |
1892 if (Gear^.dY < _0) then newY := -newY; |
1877 Gear^.dX := newx; |
1893 newx:= newy * Gear^.dX / Gear^.dY; |
1878 Gear^.dY := newy; |
1894 Gear^.dX := newx; |
1879 dec(Gear^.Timer); |
1895 Gear^.dY := newy; |
1880 end |
1896 dec(Gear^.Timer) |
1881 else |
1897 end |
1882 Gear^.Timer:= 0 |
1898 else |
1883 end; |
1899 Gear^.Timer:= 0 |
1884 |
1900 end |
1885 if (Gear^.Timer > 0) and (Gear^.Timer < 5000) and ((Gear^.Timer mod 20) = 0) then doStepDiggingGear(Gear); |
1901 end; |
1886 |
|
1887 if (Gear^.Timer = 0) |
|
1888 or ((Gear^.Timer < 5000) |
|
1889 and not TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) |
|
1890 and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) then |
|
1891 begin //out of time or exited ground |
|
1892 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1893 DeleteGear(Gear); |
|
1894 exit |
|
1895 end; |
|
1896 |
|
1897 if (Gear^.Timer < 5000) then dec(Gear^.Timer); |
|
1898 end; |
|