hedgewars/GSHandlers.inc
changeset 1918 975d5061712f
parent 1915 c357f5b55320
child 1919 390d3f685a80
equal deleted inserted replaced
1917:c94045b70142 1918:975d5061712f
    17  *)
    17  *)
    18 
    18 
    19 procedure doStepDrowningGear(Gear: PGear); forward;
    19 procedure doStepDrowningGear(Gear: PGear); forward;
    20 
    20 
    21 function CheckGearDrowning(Gear: PGear): boolean;
    21 function CheckGearDrowning(Gear: PGear): boolean;
    22 begin
    22 var skipSpeed, skipAngle, skipDecay: hwFloat;
       
    23 begin
       
    24 // probably needs tweaking. might need to be in a case statement based upon gear type
       
    25 //(not Gear^.dY.isNegative) and  this should not be necessary
    23 if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then
    26 if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then
    24 	begin
    27     begin
    25 	CheckGearDrowning:= true;
    28     skipSpeed:= _0_25;  // was 0.36 - couldn't manage baseball bat. Tiy's build is 0.36...
    26 	Gear^.State:= gstDrowning;
    29     skipAngle:= _1 + _0_9;  // these should perhaps also be constants, once work out what proper values are
    27 	Gear^.doStep:= @doStepDrowningGear;
    30     skipDecay:= _0_87;  // this could perhaps be a tiny bit higher.
    28 	PlaySound(sndSplash, false, nil)
    31     if  ((Gear^.dX*Gear^.dX+Gear^.dY*Gear^.dY) > skipSpeed) and
    29 	end else
    32         (hwAbs(Gear^.dX/Gear^.dY) > skipAngle) then
       
    33        begin
       
    34        Gear^.dY.isNegative:= true;
       
    35        Gear^.dY:=Gear^.dY*skipDecay;
       
    36        Gear^.dX:=Gear^.dX*skipDecay;
       
    37        CheckGearDrowning:= false
       
    38        end
       
    39     else
       
    40         begin
       
    41         CheckGearDrowning:= true;
       
    42         Gear^.State:= gstDrowning;
       
    43         Gear^.doStep:= @doStepDrowningGear;
       
    44         end;
       
    45     PlaySound(sndSplash, false, nil)
       
    46     end
       
    47     else
    30 	CheckGearDrowning:= false
    48 	CheckGearDrowning:= false
    31 end;
    49 end;
    32 
    50 
    33 procedure CheckCollision(Gear: PGear);
    51 procedure CheckCollision(Gear: PGear);
    34 begin
    52 begin