839 //////////////////////////////////////////////////////////////////////////////// |
840 //////////////////////////////////////////////////////////////////////////////// |
840 procedure doStepBeeWork(Gear: PGear); |
841 procedure doStepBeeWork(Gear: PGear); |
841 var |
842 var |
842 t: hwFloat; |
843 t: hwFloat; |
843 gX,gY,i: LongInt; |
844 gX,gY,i: LongInt; |
844 nuw: boolean; |
845 uw, nuw: boolean; |
845 flower: PVisualGear; |
846 flower: PVisualGear; |
846 |
847 |
847 const uw: boolean = false; |
|
848 begin |
848 begin |
849 AllInactive := false; |
849 AllInactive := false; |
850 gX := hwRound(Gear^.X); |
850 gX := hwRound(Gear^.X); |
851 gY := hwRound(Gear^.Y); |
851 gY := hwRound(Gear^.Y); |
852 nuw := (cWaterLine < gy + Gear^.Radius); |
852 uw := (Gear^.Tag <> 0); // was bee underwater last tick? |
853 if nuw and not uw then |
853 nuw := (cWaterLine < gy + Gear^.Radius); // is bee underwater now? |
|
854 |
|
855 // if water entered or left |
|
856 if nuw <> uw then |
854 begin |
857 begin |
855 AddVisualGear(gX, cWaterLine, vgtSplash); |
858 AddVisualGear(gX, cWaterLine, vgtSplash); |
856 AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet); |
859 AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet); |
857 AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet); |
860 AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet); |
858 AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet); |
861 AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet); |
859 AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet); |
862 AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet); |
860 StopSound(Gear^.SoundChannel); |
863 StopSound(Gear^.SoundChannel); |
861 Gear^.SoundChannel := LoopSound(sndBeeWater); |
864 if nuw then |
862 uw := nuw |
865 begin |
863 end |
866 Gear^.SoundChannel := LoopSound(sndBeeWater); |
864 else if not nuw and uw then |
867 Gear^.Tag := 1; |
865 begin |
868 end |
866 AddVisualGear(gX, cWaterLine, vgtSplash); |
869 else |
867 StopSound(Gear^.SoundChannel); |
870 begin |
868 Gear^.SoundChannel := LoopSound(sndBee); |
871 Gear^.SoundChannel := LoopSound(sndBee); |
869 uw := nuw |
872 Gear^.Tag := 0; |
870 end; |
873 end; |
871 |
874 end; |
872 |
875 |
873 if (GameTicks and $F) = 0 then |
876 |
874 begin |
877 if Gear^.Timer = 0 then |
875 if (GameTicks and $30) = 0 then |
878 Gear^.RenderTimer:= false |
876 AddVisualGear(gX, gY, vgtBeeTrace); |
879 else |
877 Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (Gear^.Target.X - gX)); |
880 begin |
878 Gear^.dY := Gear^.Elasticity * (Gear^.dY + _0_000064 * (Gear^.Target.Y - gY)); |
881 if (GameTicks and $F) = 0 then |
879 // make sure new speed isn't higher than original one (which we stored in Friction variable) |
882 begin |
880 t := Gear^.Friction / Distance(Gear^.dX, Gear^.dY); |
883 if (GameTicks and $30) = 0 then |
881 Gear^.dX := Gear^.dX * t; |
884 AddVisualGear(gX, gY, vgtBeeTrace); |
882 Gear^.dY := Gear^.dY * t; |
885 Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (Gear^.Target.X - gX)); |
883 end; |
886 Gear^.dY := Gear^.Elasticity * (Gear^.dY + _0_000064 * (Gear^.Target.Y - gY)); |
884 |
887 // make sure new speed isn't higher than original one (which we stored in Friction variable) |
885 Gear^.X := Gear^.X + Gear^.dX; |
888 t := Gear^.Friction / Distance(Gear^.dX, Gear^.dY); |
886 Gear^.Y := Gear^.Y + Gear^.dY; |
889 Gear^.dX := Gear^.dX * t; |
|
890 Gear^.dY := Gear^.dY * t; |
|
891 end; |
|
892 |
|
893 Gear^.X := Gear^.X + Gear^.dX; |
|
894 Gear^.Y := Gear^.Y + Gear^.dY; |
|
895 |
|
896 end; |
|
897 |
887 |
898 |
888 CheckCollision(Gear); |
899 CheckCollision(Gear); |
889 dec(Gear^.Timer); |
900 if ((Gear^.State and gstCollision) <> 0) then |
890 if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then |
|
891 begin |
901 begin |
892 StopSound(Gear^.SoundChannel); |
902 StopSound(Gear^.SoundChannel); |
893 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound); |
903 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound); |
894 for i:= 0 to 31 do |
904 for i:= 0 to 31 do |
895 begin |
905 begin |