hedgewars/uLandGraphics.pas
changeset 5332 b29d60c7cac7
parent 5322 1bcc12a30d5d
child 5349 ce527b35d063
equal deleted inserted replaced
5330:0f31c8ab064b 5332:b29d60c7cac7
   478 //  - (dX, dY) - direction, vector of length = 0.5
   478 //  - (dX, dY) - direction, vector of length = 0.5
   479 //
   479 //
   480 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
   480 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
   481 var nx, ny, dX8, dY8: hwFloat;
   481 var nx, ny, dX8, dY8: hwFloat;
   482     i, t, tx, ty, stX, stY, ddy, ddx: Longint;
   482     i, t, tx, ty, stX, stY, ddy, ddx: Longint;
       
   483     despeckle : Boolean;
   483 begin  // (-dY, dX) is (dX, dY) rotated by PI/2
   484 begin  // (-dY, dX) is (dX, dY) rotated by PI/2
   484 stY:= hwRound(Y);
   485 stY:= hwRound(Y);
   485 stX:= hwRound(X);
   486 stX:= hwRound(X);
       
   487 
       
   488 despeckle:= HalfWidth > 1;
   486 
   489 
   487 nx:= X + dY * (HalfWidth + 8);
   490 nx:= X + dY * (HalfWidth + 8);
   488 ny:= Y - dX * (HalfWidth + 8);
   491 ny:= Y - dX * (HalfWidth + 8);
   489 
   492 
   490 dX8:= dX * 8;
   493 dX8:= dX * 8;
   503        ((tx and LAND_WIDTH_MASK) = 0) and
   506        ((tx and LAND_WIDTH_MASK) = 0) and
   504        (((Land[ty, tx] and lfBasic) <> 0) or
   507        (((Land[ty, tx] and lfBasic) <> 0) or
   505        ((Land[ty, tx] and lfObject) <> 0)) then
   508        ((Land[ty, tx] and lfObject) <> 0)) then
   506         begin
   509         begin
   507         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   510         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   508             if (cReducedQuality and rqBlurryLand) = 0 then
   511         if despeckle then LandDirty[ty div 32, tx div 32]:= 1;
       
   512         if (cReducedQuality and rqBlurryLand) = 0 then
   509             LandPixels[ty, tx]:= cExplosionBorderColor
   513             LandPixels[ty, tx]:= cExplosionBorderColor
   510             else
   514         else LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   511             LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
       
   512         end
   515         end
   513     end;
   516     end;
   514     nx:= nx - dY;
   517     nx:= nx - dY;
   515     ny:= ny + dX;
   518     ny:= ny + dX;
   516     end;
   519     end;
   529        ((tx and LAND_WIDTH_MASK) = 0) and
   532        ((tx and LAND_WIDTH_MASK) = 0) and
   530        (((Land[ty, tx] and lfBasic) <> 0) or
   533        (((Land[ty, tx] and lfBasic) <> 0) or
   531        ((Land[ty, tx] and lfObject) <> 0)) then
   534        ((Land[ty, tx] and lfObject) <> 0)) then
   532         begin
   535         begin
   533         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   536         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   534             if (cReducedQuality and rqBlurryLand) = 0 then
   537         if despeckle then LandDirty[ty div 32, tx div 32]:= 1;
   535         LandPixels[ty, tx]:= cExplosionBorderColor
   538         if (cReducedQuality and rqBlurryLand) = 0 then
   536             else
   539             LandPixels[ty, tx]:= cExplosionBorderColor
   537         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   540         else LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   538 
       
   539         end
   541         end
   540     end;
   542     end;
   541     X:= nx;
   543     X:= nx;
   542     Y:= ny;
   544     Y:= ny;
   543     for t:= 0 to ticks do
   545     for t:= 0 to ticks do
   573        ((tx and LAND_WIDTH_MASK) = 0) and
   575        ((tx and LAND_WIDTH_MASK) = 0) and
   574        (((Land[ty, tx] and lfBasic) <> 0) or
   576        (((Land[ty, tx] and lfBasic) <> 0) or
   575        ((Land[ty, tx] and lfObject) <> 0)) then
   577        ((Land[ty, tx] and lfObject) <> 0)) then
   576         begin
   578         begin
   577         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   579         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
       
   580         if despeckle then LandDirty[ty div 32, tx div 32]:= 1;
   578         if (cReducedQuality and rqBlurryLand) = 0 then
   581         if (cReducedQuality and rqBlurryLand) = 0 then
   579         LandPixels[ty, tx]:= cExplosionBorderColor
   582             LandPixels[ty, tx]:= cExplosionBorderColor
   580         else
   583         else LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   581         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
       
   582 
       
   583         end
   584         end
   584     end;
   585     end;
   585     nx:= nx - dY;
   586     nx:= nx - dY;
   586     ny:= ny + dX;
   587     ny:= ny + dX;
   587     end;
   588     end;
   600        ((tx and LAND_WIDTH_MASK) = 0) and
   601        ((tx and LAND_WIDTH_MASK) = 0) and
   601        (((Land[ty, tx] and lfBasic) <> 0) or
   602        (((Land[ty, tx] and lfBasic) <> 0) or
   602        ((Land[ty, tx] and lfObject) <> 0)) then
   603        ((Land[ty, tx] and lfObject) <> 0)) then
   603         begin
   604         begin
   604         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   605         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
       
   606         if despeckle then LandDirty[ty div 32, tx div 32]:= 1;
   605         if (cReducedQuality and rqBlurryLand) = 0 then
   607         if (cReducedQuality and rqBlurryLand) = 0 then
   606         LandPixels[ty, tx]:= cExplosionBorderColor
   608             LandPixels[ty, tx]:= cExplosionBorderColor
   607         else
   609         else LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   608         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
       
   609         end
   610         end
   610     end;
   611     end;
   611     nx:= nx - dY;
   612     nx:= nx - dY;
   612     ny:= ny + dX;
   613     ny:= ny + dX;
   613     end;
   614     end;