hedgewars/uLandGraphics.pas
changeset 1760 55a1edd97911
parent 1753 2ccba26f1aa4
child 1761 c7038eade58d
equal deleted inserted replaced
1759:88b0cf9d6de5 1760:55a1edd97911
    41 
    41 
    42 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
    42 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
    43 var i: LongInt;
    43 var i: LongInt;
    44 begin
    44 begin
    45 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    45 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    46     for i:= max(x - dx, 0) to min(x + dx, 4095) do 
    46     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do 
    47         if Land[y + dy, i] <> COLOR_INDESTRUCTIBLE then
    47         if Land[y + dy, i] <> COLOR_INDESTRUCTIBLE then
    48             Land[y + dy, i]:= Value;
    48             Land[y + dy, i]:= Value;
    49 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    49 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    50    for i:= max(x - dx, 0) to min(x + dx, 4095) do 
    50    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do 
    51         if Land[y - dy, i] <> COLOR_INDESTRUCTIBLE then
    51         if Land[y - dy, i] <> COLOR_INDESTRUCTIBLE then
    52             Land[y - dy, i]:= Value;
    52             Land[y - dy, i]:= Value;
    53 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    53 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    54     for i:= max(x - dy, 0) to min(x + dy, 4095) do 
    54     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do 
    55         if Land[y + dx, i] <> COLOR_INDESTRUCTIBLE then
    55         if Land[y + dx, i] <> COLOR_INDESTRUCTIBLE then
    56             Land[y + dx, i]:= Value;
    56             Land[y + dx, i]:= Value;
    57 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    57 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    58     for i:= max(x - dy, 0) to min(x + dy, 4095) do 
    58     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do 
    59         if Land[y - dx, i] <> COLOR_INDESTRUCTIBLE then
    59         if Land[y - dx, i] <> COLOR_INDESTRUCTIBLE then
    60             Land[y - dx, i]:= Value;
    60             Land[y - dx, i]:= Value;
    61 end;
    61 end;
    62 
    62 
    63 procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet: boolean);
    63 procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet: boolean);
    64 var i: LongInt;
    64 var i: LongInt;
    65 begin
    65 begin
    66 if not doSet then
    66 if not doSet then
    67    begin
    67    begin
    68    if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    68    if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    69       for i:= max(x - dx, 0) to min(x + dx, 4095) do
    69       for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
    70           if (Land[y + dy, i] > 0) then dec(Land[y + dy, i]); // check > 0 because explosion can erase collision data
    70           if (Land[y + dy, i] > 0) then dec(Land[y + dy, i]); // check > 0 because explosion can erase collision data
    71    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    71    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    72       for i:= max(x - dx, 0) to min(x + dx, 4095) do
    72       for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
    73           if (Land[y - dy, i] > 0) then dec(Land[y - dy, i]);
    73           if (Land[y - dy, i] > 0) then dec(Land[y - dy, i]);
    74    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    74    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    75       for i:= max(x - dy, 0) to min(x + dy, 4095) do
    75       for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
    76           if (Land[y + dx, i] > 0) then dec(Land[y + dx, i]);
    76           if (Land[y + dx, i] > 0) then dec(Land[y + dx, i]);
    77    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    77    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    78       for i:= max(x - dy, 0) to min(x + dy, 4095) do
    78       for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
    79           if (Land[y - dx, i] > 0) then dec(Land[y - dx, i]);
    79           if (Land[y - dx, i] > 0) then dec(Land[y - dx, i]);
    80    end else
    80    end else
    81    begin
    81    begin
    82    if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    82    if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    83       for i:= max(x - dx, 0) to min(x + dx, 4095) do inc(Land[y + dy, i]);
    83       for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do inc(Land[y + dy, i]);
    84    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    84    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    85       for i:= max(x - dx, 0) to min(x + dx, 4095) do inc(Land[y - dy, i]);
    85       for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do inc(Land[y - dy, i]);
    86    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    86    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    87       for i:= max(x - dy, 0) to min(x + dy, 4095) do inc(Land[y + dx, i]);
    87       for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do inc(Land[y + dx, i]);
    88    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    88    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    89       for i:= max(x - dy, 0) to min(x + dy, 4095) do inc(Land[y - dx, i]);
    89       for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do inc(Land[y - dx, i]);
    90    end
    90    end
    91 end;
    91 end;
    92 
    92 
    93 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
    93 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
    94 var dx, dy, d: LongInt;
    94 var dx, dy, d: LongInt;
   132 
   132 
   133 procedure FillLandCircleLines0(x, y, dx, dy: LongInt);
   133 procedure FillLandCircleLines0(x, y, dx, dy: LongInt);
   134 var i: LongInt;
   134 var i: LongInt;
   135 begin
   135 begin
   136 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   136 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   137     for i:= max(x - dx, 0) to min(x + dx, 4095) do 
   137     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do 
   138         if Land[y + dy, i] <> COLOR_INDESTRUCTIBLE then
   138         if Land[y + dy, i] <> COLOR_INDESTRUCTIBLE then
   139             LandPixels[y + dy, i]:= 0;
   139             LandPixels[y + dy, i]:= 0;
   140 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   140 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   141     for i:= max(x - dx, 0) to min(x + dx, 4095) do 
   141     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do 
   142         if Land[y - dy, i] <> COLOR_INDESTRUCTIBLE then
   142         if Land[y - dy, i] <> COLOR_INDESTRUCTIBLE then
   143              LandPixels[y - dy, i]:= 0;
   143              LandPixels[y - dy, i]:= 0;
   144 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   144 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   145     for i:= max(x - dy, 0) to min(x + dy, 4095) do 
   145     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do 
   146         if Land[y + dx, i] <> COLOR_INDESTRUCTIBLE then
   146         if Land[y + dx, i] <> COLOR_INDESTRUCTIBLE then
   147             LandPixels[y + dx, i]:= 0;
   147             LandPixels[y + dx, i]:= 0;
   148 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   148 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   149     for i:= max(x - dy, 0) to min(x + dy, 4095) do 
   149     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do 
   150         if Land[y - dx, i] <> COLOR_INDESTRUCTIBLE then
   150         if Land[y - dx, i] <> COLOR_INDESTRUCTIBLE then
   151              LandPixels[y - dx, i]:= 0;
   151              LandPixels[y - dx, i]:= 0;
   152 end;
   152 end;
   153 
   153 
   154 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   154 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   155 var i: LongInt;
   155 var i: LongInt;
   156 begin
   156 begin
   157 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   157 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   158    for i:= max(x - dx, 0) to min(x + dx, 4095) do
   158    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   159        if Land[y + dy, i] = COLOR_LAND then 
   159        if Land[y + dy, i] = COLOR_LAND then 
   160           begin
   160           begin
   161           LandPixels[y + dy, i]:= cExplosionBorderColor;
   161           LandPixels[y + dy, i]:= cExplosionBorderColor;
   162 //          Despeckle(y + dy, i);
   162 //          Despeckle(y + dy, i);
   163           LandDirty[(y + dy) div 32, i div 32]:= 1;
   163           LandDirty[(y + dy) div 32, i div 32]:= 1;
   164           end;
   164           end;
   165 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   165 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   166    for i:= max(x - dx, 0) to min(x + dx, 4095) do
   166    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   167        if Land[y - dy, i] = COLOR_LAND then
   167        if Land[y - dy, i] = COLOR_LAND then
   168           begin
   168           begin
   169           LandPixels[y - dy, i]:= cExplosionBorderColor;
   169           LandPixels[y - dy, i]:= cExplosionBorderColor;
   170 //          Despeckle(y - dy, i);
   170 //          Despeckle(y - dy, i);
   171           LandDirty[(y - dy) div 32, i div 32]:= 1;
   171           LandDirty[(y - dy) div 32, i div 32]:= 1;
   172           end;
   172           end;
   173 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   173 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   174    for i:= max(x - dy, 0) to min(x + dy, 4095) do
   174    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   175        if Land[y + dx, i] = COLOR_LAND then
   175        if Land[y + dx, i] = COLOR_LAND then
   176            begin
   176            begin
   177            LandPixels[y + dx, i]:= cExplosionBorderColor;
   177            LandPixels[y + dx, i]:= cExplosionBorderColor;
   178 //           Despeckle(y + dx, i);
   178 //           Despeckle(y + dx, i);
   179            LandDirty[(y + dx) div 32, i div 32]:= 1;
   179            LandDirty[(y + dx) div 32, i div 32]:= 1;
   180            end;
   180            end;
   181 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   181 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   182    for i:= max(x - dy, 0) to min(x + dy, 4095) do
   182    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   183        if Land[y - dx, i] = COLOR_LAND then
   183        if Land[y - dx, i] = COLOR_LAND then
   184           begin
   184           begin
   185           LandPixels[y - dx, i]:= cExplosionBorderColor;
   185           LandPixels[y - dx, i]:= cExplosionBorderColor;
   186 //          Despeckle(y - dx, i);
   186 //          Despeckle(y - dx, i);
   187           LandDirty[(y - dx) div 32, i div 32]:= 1;
   187           LandDirty[(y - dx) div 32, i div 32]:= 1;
   224      inc(dx)
   224      inc(dx)
   225      end;
   225      end;
   226   if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy);
   226   if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy);
   227 
   227 
   228 d:= max(Y - Radius - 1, 0);
   228 d:= max(Y - Radius - 1, 0);
   229 dy:= min(Y + Radius + 1, 2047) - d;
   229 dy:= min(Y + Radius + 1, LAND_HEIGHT) - d;
   230 UpdateLandTexture(d, dy)
   230 UpdateLandTexture(d, dy)
   231 end;
   231 end;
   232 
   232 
   233 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
   233 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
   234 var tx, ty, i: LongInt;
   234 var tx, ty, i: LongInt;
   443 			until not updatedCell;
   443 			until not updatedCell;
   444 		LandDirty[y, x]:= 0;
   444 		LandDirty[y, x]:= 0;
   445 		end;
   445 		end;
   446 	
   446 	
   447 	if updatedRow then
   447 	if updatedRow then
   448 		if y = 63 then
   448 		UpdateLandTexture(y * 32, 32);
   449 			UpdateLandTexture(LAND_HEIGHT-31, 31)
       
   450 		else
       
   451 			UpdateLandTexture(y*32, 32);
       
   452 	end;
   449 	end;
   453 end;
   450 end;
   454 
   451 
   455 end.
   452 end.