hedgewars/uGearsHandlersMess.pas
changeset 14287 6015b74eea55
parent 14209 4b418709b1cf
child 14289 a3531b520efb
equal deleted inserted replaced
14286:e754b516cc35 14287:6015b74eea55
   306 
   306 
   307 Gear^.Y := Gear^.Y + cDrownSpeed;
   307 Gear^.Y := Gear^.Y + cDrownSpeed;
   308 
   308 
   309 if cWaterLine > hwRound(Gear^.Y) + Gear^.Radius then
   309 if cWaterLine > hwRound(Gear^.Y) + Gear^.Radius then
   310     begin
   310     begin
   311     if LongInt(leftX) + Gear^.Radius > hwRound(Gear^.X) then
   311     if leftX + Gear^.Radius > hwRound(Gear^.X) then
   312         Gear^.X := Gear^.X - cDrownSpeed
   312         Gear^.X := Gear^.X - cDrownSpeed
   313     else
   313     else
   314         Gear^.X := Gear^.X + cDrownSpeed;
   314         Gear^.X := Gear^.X + cDrownSpeed;
   315     end
   315     end
   316 else
   316 else
   373         begin
   373         begin
   374         // Collision with land that *just* behind the other side of the world wrap edge
   374         // Collision with land that *just* behind the other side of the world wrap edge
   375         if (not Gear^.Sticky) then
   375         if (not Gear^.Sticky) then
   376             begin
   376             begin
   377             Gear^.X:= tX;
   377             Gear^.X:= tX;
   378             Gear^.dX.isNegative:= (gX > LongInt(leftX) + Gear^.Radius*2);
   378             Gear^.dX.isNegative:= (gX > leftX + Gear^.Radius*2);
   379             Gear^.dX := Gear^.dX * Gear^.Friction;
   379             Gear^.dX := Gear^.dX * Gear^.Friction;
   380             end;
   380             end;
   381         Gear^.State := Gear^.State or gstCollision;
   381         Gear^.State := Gear^.State or gstCollision;
   382         end;
   382         end;
   383 
   383 
   840     CheckCollision(Gear);
   840     CheckCollision(Gear);
   841     if ((Gear^.State and gstCollision) <> 0) or ((Gear^.State and gstMoving) = 0) then
   841     if ((Gear^.State and gstCollision) <> 0) or ((Gear^.State and gstMoving) = 0) then
   842         draw:= true;
   842         draw:= true;
   843     xx:= hwRound(Gear^.X);
   843     xx:= hwRound(Gear^.X);
   844     yy:= hwRound(Gear^.Y);
   844     yy:= hwRound(Gear^.Y);
   845     if draw and (WorldEdge = weWrap) and ((xx < LongInt(leftX) + 3) or (xx > LongInt(rightX) - 3)) then
   845     if draw and (WorldEdge = weWrap) and ((xx < leftX + 3) or (xx > rightX - 3)) then
   846         begin
   846         begin
   847         if xx < LongInt(leftX) + 3 then
   847         if xx < leftX + 3 then
   848              xx:= rightX-3
   848              xx:= rightX-3
   849         else xx:= leftX+3;
   849         else xx:= leftX+3;
   850         Gear^.X:= int2hwFloat(xx)
   850         Gear^.X:= int2hwFloat(xx)
   851         end
   851         end
   852     end
   852     end
  3679         * Otherwise: Walk normally
  3679         * Otherwise: Walk normally
  3680         *)
  3680         *)
  3681         begin
  3681         begin
  3682         // Update coordinates
  3682         // Update coordinates
  3683         tdx:=Gear^.X;
  3683         tdx:=Gear^.X;
  3684         if (hwRound(Gear^.X) < LongInt(leftX)) then
  3684         if (hwRound(Gear^.X) < leftX) then
  3685              Gear^.X:= Gear^.X + int2hwfloat(rightX - leftX)
  3685              Gear^.X:= Gear^.X + int2hwfloat(rightX - leftX)
  3686         else Gear^.X:= Gear^.X - int2hwfloat(rightX - leftX);
  3686         else Gear^.X:= Gear^.X - int2hwfloat(rightX - leftX);
  3687 
  3687 
  3688         Gear^.Tag:= 0;
  3688         Gear^.Tag:= 0;
  3689         if ((TestCollisionXwithGear(Gear, 1) <> 0) or (TestCollisionXwithGear(Gear, -1) <> 0)) then
  3689         if ((TestCollisionXwithGear(Gear, 1) <> 0) or (TestCollisionXwithGear(Gear, -1) <> 0)) then
  5429         x := hwRound(Gear^.X);
  5429         x := hwRound(Gear^.X);
  5430         y := hwRound(Gear^.Y);
  5430         y := hwRound(Gear^.Y);
  5431 
  5431 
  5432         if WorldEdge = weWrap then
  5432         if WorldEdge = weWrap then
  5433             begin
  5433             begin
  5434             if x > LongInt(rightX) then
  5434             if x > rightX then
  5435                 repeat
  5435                 repeat
  5436                     dec(x,  playWidth);
  5436                     dec(x,  playWidth);
  5437                     dec(rx, playWidth);
  5437                     dec(rx, playWidth);
  5438                 until x <= LongInt(rightX)
  5438                 until x <= rightX
  5439             else if x < LongInt(leftX) then
  5439             else if x < leftX then
  5440                 repeat
  5440                 repeat
  5441                     inc(x,  playWidth);
  5441                     inc(x,  playWidth);
  5442                     inc(rx, playWidth);
  5442                     inc(rx, playWidth);
  5443                 until x >= LongInt(leftX);
  5443                 until x >= leftX;
  5444             end
  5444             end
  5445         else if (WorldEdge = weBounce) then
  5445         else if (WorldEdge = weBounce) then
  5446             begin
  5446             begin
  5447             if (not justBounced) and ((x > LongInt(rightX)) or (x < LongInt(leftX))) then
  5447             if (not justBounced) and ((x > rightX) or (x < leftX)) then
  5448                 begin
  5448                 begin
  5449                 // reflect
  5449                 // reflect
  5450                 lX:= lX - ldX + ((oX - lX) * 2);
  5450                 lX:= lX - ldX + ((oX - lX) * 2);
  5451                 lY:= lY - ldY;
  5451                 lY:= lY - ldY;
  5452                 Gear^.X:= oX;
  5452                 Gear^.X:= oX;
  6388                         ((Target.X and LAND_WIDTH_MASK  = 0) and
  6388                         ((Target.X and LAND_WIDTH_MASK  = 0) and
  6389                          (Target.Y and LAND_HEIGHT_MASK = 0) and
  6389                          (Target.Y and LAND_HEIGHT_MASK = 0) and
  6390                          (Land[Target.Y, Target.X] = lfIce) and
  6390                          (Land[Target.Y, Target.X] = lfIce) and
  6391                          ((Target.Y+iceHeight+5 > cWaterLine) or
  6391                          ((Target.Y+iceHeight+5 > cWaterLine) or
  6392                           ((WorldEdge = weSea) and
  6392                           ((WorldEdge = weSea) and
  6393                            ((Target.X+iceHeight+5 > LongInt(rightX)) or
  6393                            ((Target.X+iceHeight+5 > rightX) or
  6394                             (Target.X-iceHeight-5 < LongInt(leftX)))))
  6394                             (Target.X-iceHeight-5 < leftX))))
  6395                          ) then
  6395                          ) then
  6396                     begin
  6396                     begin
  6397                     if Timer = iceWaitCollision then
  6397                     if Timer = iceWaitCollision then
  6398                         begin
  6398                         begin
  6399                         Timer := iceCollideWithWater;
  6399                         Timer := iceCollideWithWater;
  6498                     PlaySound(sndHogFreeze);
  6498                     PlaySound(sndHogFreeze);
  6499                     if CheckCoordInWater(Target.X, Target.Y) then
  6499                     if CheckCoordInWater(Target.X, Target.Y) then
  6500                         DrawIceBreak(Target.X, Target.Y, iceRadius, iceHeight)
  6500                         DrawIceBreak(Target.X, Target.Y, iceRadius, iceHeight)
  6501                     else if Target.Y+iceHeight+5 > cWaterLine then
  6501                     else if Target.Y+iceHeight+5 > cWaterLine then
  6502                         DrawIceBreak(Target.X, Target.Y+iceHeight+5, iceRadius, iceHeight)
  6502                         DrawIceBreak(Target.X, Target.Y+iceHeight+5, iceRadius, iceHeight)
  6503                     else if Target.X+iceHeight+5 > LongInt(rightX) then
  6503                     else if Target.X+iceHeight+5 > rightX then
  6504                         DrawIceBreak(Target.X+iceHeight+5, Target.Y, iceRadius, iceHeight)
  6504                         DrawIceBreak(Target.X+iceHeight+5, Target.Y, iceRadius, iceHeight)
  6505                     else
  6505                     else
  6506                         DrawIceBreak(Target.X-iceHeight-5, Target.Y, iceRadius, iceHeight);
  6506                         DrawIceBreak(Target.X-iceHeight-5, Target.Y, iceRadius, iceHeight);
  6507                     SetAllHHToActive;
  6507                     SetAllHHToActive;
  6508                     Timer := iceWaitCollision;
  6508                     Timer := iceWaitCollision;
  6611         exit
  6611         exit
  6612         end;
  6612         end;
  6613 if (Gear^.State and gstTmpFlag <> 0) or (GameTicks and $7 = 0) then
  6613 if (Gear^.State and gstTmpFlag <> 0) or (GameTicks and $7 = 0) then
  6614     begin
  6614     begin
  6615     doStepFallingGear(Gear);
  6615     doStepFallingGear(Gear);
  6616     if (Gear^.Tag = 1) and (GameTicks and $FF = 0) and (hwRound(Gear^.X) < LongInt(leftX)) or (hwRound(Gear^.X) > LongInt(rightX)) or (hwRound(Gear^.Y) < LongInt(topY)) then
  6616     if (Gear^.Tag = 1) and (GameTicks and $FF = 0) and (hwRound(Gear^.X) < leftX) or (hwRound(Gear^.X) > rightX) or (hwRound(Gear^.Y) < LongInt(topY)) then
  6617         begin
  6617         begin
  6618         Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX);
  6618         Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX);
  6619         Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY);
  6619         Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY);
  6620         Gear^.dX:= _90-(GetRandomf*_360);
  6620         Gear^.dX:= _90-(GetRandomf*_360);
  6621         Gear^.dY:= _90-(GetRandomf*_360)
  6621         Gear^.dY:= _90-(GetRandomf*_360)