6837 and (TestCollisionYwithGear(Gear, 1) = 0) then Gear^.State:= Gear^.State and (not gstCollision) or gstMoving; |
6836 and (TestCollisionYwithGear(Gear, 1) = 0) then Gear^.State:= Gear^.State and (not gstCollision) or gstMoving; |
6838 end |
6837 end |
6839 end; |
6838 end; |
6840 |
6839 |
6841 //////////////////////////////////////////////////////////////////////////////// |
6840 //////////////////////////////////////////////////////////////////////////////// |
6842 procedure doStepDuck(Gear: PGear); |
|
6843 begin |
|
6844 // Mirror duck on bounce world edge, even turn around later |
|
6845 if WorldWrap(Gear) and (WorldEdge = weBounce) then |
|
6846 begin |
|
6847 Gear^.Tag:= Gear^.Tag * -1; |
|
6848 if Gear^.Pos = 2 then |
|
6849 Gear^.Pos:= 1 |
|
6850 else if Gear^.Pos = 1 then |
|
6851 Gear^.Pos:= 2 |
|
6852 else if Gear^.Pos = 5 then |
|
6853 Gear^.Pos:= 6 |
|
6854 else if Gear^.Pos = 5 then |
|
6855 Gear^.Pos:= 5; |
|
6856 end; |
|
6857 |
|
6858 AllInactive := false; |
|
6859 |
|
6860 // Duck falls (Pos = 0) |
|
6861 if Gear^.Pos = 0 then |
|
6862 doStepFallingGear(Gear); |
|
6863 |
|
6864 (* Check if duck is near water surface |
|
6865 (Karma is distance from water) *) |
|
6866 if (Gear^.Pos <> 1) and (Gear^.Pos <> 2) and (cWaterLine <= hwRound(Gear^.Y) + Gear^.Karma) then |
|
6867 begin |
|
6868 if cWaterLine = hwRound(Gear^.Y) + Gear^.Karma then |
|
6869 begin |
|
6870 // Let's make that duck swim! |
|
6871 // Does the duck come FROM the Sea edge? (left or right) |
|
6872 if (((Gear^.Pos = 3) or (Gear^.Pos = 7)) and (cWindSpeed > _0)) or (((Gear^.Pos = 4) or (Gear^.Pos = 8)) and (cWindSpeed < _0)) then |
|
6873 begin |
|
6874 PlaySound(sndDuckWater); |
|
6875 Gear^.DirAngle:= 0; |
|
6876 Gear^.Pos:= 1; |
|
6877 Gear^.dY:= _0; |
|
6878 end; |
|
6879 |
|
6880 // Duck comes either falling (usual case) or was rising from below |
|
6881 if (Gear^.Pos = 0) or (Gear^.Pos = 5) or (Gear^.Pos = 6) then |
|
6882 begin |
|
6883 PlaySound(sndDroplet2); |
|
6884 if Gear^.dY > _0_4 then |
|
6885 PlaySound(sndDuckWater); |
|
6886 Gear^.Pos:= 1; |
|
6887 Gear^.dY:= _0; |
|
6888 end; |
|
6889 end |
|
6890 else if Gear^.Pos = 0 then |
|
6891 Gear^.Pos:= 5; |
|
6892 end; |
|
6893 |
|
6894 // Manual speed handling when duck is on water |
|
6895 if Gear^.Pos <> 0 then |
|
6896 begin |
|
6897 Gear^.X:= Gear^.X + Gear^.dX; |
|
6898 Gear^.Y:= Gear^.Y + Gear^.dY; |
|
6899 end; |
|
6900 |
|
6901 // Handle speed |
|
6902 // 1-4: On water: Let's swim! |
|
6903 if Gear^.Pos = 1 then |
|
6904 // On water (normal) |
|
6905 Gear^.dX:= cWindSpeed * Gear^.Damage |
|
6906 else if Gear^.Pos = 2 then |
|
6907 // On water, mirrored (after bounce edge bounce) |
|
6908 Gear^.dX:= -cWindSpeed * Gear^.Damage |
|
6909 else if Gear^.Pos = 3 then |
|
6910 // On left Sea edge |
|
6911 Gear^.dY:= cWindSpeed * Gear^.Damage |
|
6912 else if Gear^.Pos = 4 then |
|
6913 // On right Sea edge |
|
6914 Gear^.dY:= -cWindSpeed * Gear^.Damage |
|
6915 // 5-8: Underwater: Slowly rise to the surface and slightly follow wind |
|
6916 else if Gear^.Pos = 5 then |
|
6917 // Underwater (normal) |
|
6918 begin |
|
6919 Gear^.dX:= (cWindSpeed / 4) * Gear^.Damage; |
|
6920 Gear^.dY:= -_0_07; |
|
6921 end |
|
6922 else if Gear^.Pos = 6 then |
|
6923 // Underwater, mirrored duck (after bounce edge bounce) |
|
6924 begin |
|
6925 Gear^.dX:= -(cWindSpeed / 4) * Gear^.Damage; |
|
6926 Gear^.dY:= -_0_07; |
|
6927 end |
|
6928 else if Gear^.Pos = 7 then |
|
6929 // Inside left Sea edge |
|
6930 begin |
|
6931 Gear^.dX:= _0_07; |
|
6932 Gear^.dY:= (cWindSpeed / 4) * Gear^.Damage; |
|
6933 end |
|
6934 else if Gear^.Pos = 8 then |
|
6935 // Inside right Sea edge |
|
6936 begin |
|
6937 Gear^.dX:= -_0_07; |
|
6938 Gear^.dY:= -(cWindSpeed / 4) * Gear^.Damage; |
|
6939 end; |
|
6940 |
|
6941 |
|
6942 // Rotate duck and change direction when reaching Sea world edge (Pos 3 or 4) |
|
6943 if (WorldEdge = weSea) and (Gear^.Pos <> 3) and (Gear^.Pos <> 4) then |
|
6944 // Swimming TOWARDS left edge |
|
6945 if (LeftX >= hwRound(Gear^.X) - Gear^.Karma) and ((cWindSpeed < _0) or ((Gear^.Pos = 0) or (Gear^.Pos = 7))) then |
|
6946 begin |
|
6947 // Turn duck when reaching edge the first time |
|
6948 if (Gear^.Pos <> 3) and (Gear^.Pos <> 7) then |
|
6949 begin |
|
6950 if Gear^.Tag = 1 then |
|
6951 Gear^.DirAngle:= 90 |
|
6952 else |
|
6953 Gear^.DirAngle:= 270; |
|
6954 end; |
|
6955 |
|
6956 // Reaching the edge surface |
|
6957 if (LeftX = hwRound(Gear^.X) - Gear^.Karma) and (Gear^.Pos <> 3) then |
|
6958 // We are coming from the horizontal side |
|
6959 begin |
|
6960 PlaySound(sndDuckWater); |
|
6961 Gear^.dX:= _0; |
|
6962 Gear^.Pos:= 3; |
|
6963 end |
|
6964 else |
|
6965 // We are coming from inside the Sea, go into “surfacing” mode |
|
6966 Gear^.Pos:= 7; |
|
6967 |
|
6968 end |
|
6969 |
|
6970 // Swimming TOWARDS right edge (similar to left edge) |
|
6971 else if (RightX <= hwRound(Gear^.X) + Gear^.Karma) and ((cWindSpeed > _0) or ((Gear^.Pos = 0) or (Gear^.Pos = 8))) then |
|
6972 begin |
|
6973 if (Gear^.Pos <> 4) and (Gear^.Pos <> 8) then |
|
6974 begin |
|
6975 if Gear^.Tag = 1 then |
|
6976 Gear^.DirAngle:= 270 |
|
6977 else |
|
6978 Gear^.DirAngle:= 90; |
|
6979 end; |
|
6980 |
|
6981 if (RightX = hwRound(Gear^.X) + Gear^.Karma) and (Gear^.Pos <> 4) then |
|
6982 begin |
|
6983 PlaySound(sndDuckWater); |
|
6984 Gear^.dX:= _0; |
|
6985 Gear^.Pos:= 4; |
|
6986 end |
|
6987 else |
|
6988 Gear^.Pos:= 8; |
|
6989 |
|
6990 end; |
|
6991 |
|
6992 |
|
6993 if Gear^.Pos <> 0 then |
|
6994 // Manual collision check required because we don't use onStepFallingGear in this case |
|
6995 CheckCollision(Gear); |
|
6996 if (Gear^.Timer = 0) or ((Gear^.State and gstCollision) <> 0) then |
|
6997 // Explode duck |
|
6998 begin |
|
6999 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); |
|
7000 PlaySound(sndDuckDie); |
|
7001 DeleteGear(Gear); |
|
7002 exit; |
|
7003 end; |
|
7004 |
|
7005 // Update timer stuff |
|
7006 if Gear^.Timer < 6000 then |
|
7007 Gear^.RenderTimer:= true |
|
7008 else |
|
7009 Gear^.RenderTimer:= false; |
|
7010 |
|
7011 dec(Gear^.Timer); |
|
7012 end; |
|
7013 |
|
7014 //////////////////////////////////////////////////////////////////////////////// |
|
7015 procedure doStepMinigunWork(Gear: PGear); |
6841 procedure doStepMinigunWork(Gear: PGear); |
7016 var HHGear: PGear; |
6842 var HHGear: PGear; |
7017 bullet: PGear; |
6843 bullet: PGear; |
7018 rx, ry: hwFloat; |
6844 rx, ry: hwFloat; |
7019 gX, gY: LongInt; |
6845 gX, gY: LongInt; |