hedgewars/uLandGraphics.pas
changeset 1792 c30c6944bd49
parent 1761 c7038eade58d
child 1806 3c4f0886c123
equal deleted inserted replaced
1791:7c9d645d2591 1792:c30c6944bd49
    24 type PRangeArray = ^TRangeArray;
    24 type PRangeArray = ^TRangeArray;
    25      TRangeArray = array[0..31] of record
    25      TRangeArray = array[0..31] of record
    26                                    Left, Right: LongInt;
    26                                    Left, Right: LongInt;
    27                                    end;
    27                                    end;
    28 
    28 
    29 procedure SweepDirty;
    29 function SweepDirty: boolean;
    30 function Despeckle(X, Y: LongInt): boolean;
    30 function Despeckle(X, Y: LongInt): boolean;
    31 procedure DrawExplosion(X, Y, Radius: LongInt);
    31 procedure DrawExplosion(X, Y, Radius: LongInt);
    32 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
    32 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
    33 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
    33 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
    34 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
    34 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
   347 case bpp of
   347 case bpp of
   348      4: for y:= 0 to Pred(h) do
   348      4: for y:= 0 to Pred(h) do
   349             begin
   349             begin
   350             for x:= 0 to Pred(w) do
   350             for x:= 0 to Pred(w) do
   351                 if PLongword(@(p^[x * 4]))^ <> 0 then
   351                 if PLongword(@(p^[x * 4]))^ <> 0 then
   352                    if (((cpY + y) and LAND_HEIGHT_MASK) <> 0) or
   352                    if ((cpY + y) < Longint(topY)) or
   353                       (((cpX + x) and LAND_WIDTH_MASK) <> 0) or
   353                       ((cpY + y) > LAND_HEIGHT) or
       
   354                       ((cpX + x) < Longint(leftX)) or
       
   355                       ((cpX + x) > Longint(rightX)) or
   354                       (Land[cpY + y, cpX + x] <> 0) then
   356                       (Land[cpY + y, cpX + x] <> 0) then
   355                       begin
   357                       begin
   356                       if SDL_MustLock(Image) then
   358                       if SDL_MustLock(Image) then
   357                          SDL_UnlockSurface(Image);
   359                          SDL_UnlockSurface(Image);
   358                       exit(false)
   360                       exit(false)
   384             end;
   386             end;
   385      end;
   387      end;
   386 if SDL_MustLock(Image) then
   388 if SDL_MustLock(Image) then
   387    SDL_UnlockSurface(Image);
   389    SDL_UnlockSurface(Image);
   388 
   390 
   389 y:= max(cpY, 0);
   391 y:= max(cpY, topY);
   390 h:= min(cpY + Image^.h, LAND_HEIGHT) - y;
   392 h:= min(cpY + Image^.h, LAND_HEIGHT) - y;
   391 UpdateLandTexture(y, h)
   393 UpdateLandTexture(y, h)
   392 end;
   394 end;
   393 
   395 
   394 // was experimenting with applying as damage occurred.
   396 // was experimenting with applying as damage occurred.
   395 function Despeckle(X, Y: LongInt): boolean;
   397 function Despeckle(X, Y: LongInt): boolean;
   396 var nx, ny, i, j, c: LongInt;
   398 var nx, ny, i, j, c: LongInt;
   397 begin
   399 begin
   398 if (Land[Y, X] <> 0) and (Land[Y, X] <> COLOR_INDESTRUCTIBLE) then // check neighbours
   400 if (Land[Y, X] <> 0) and (Land[Y, X] <> COLOR_INDESTRUCTIBLE) and (LandPixels[Y, X] = cExplosionBorderColor)then // check neighbours
   399 	begin
   401 	begin
   400 	c:= 0;
   402 	c:= 0;
   401 	for i:= -1 to 1 do
   403 	for i:= -1 to 1 do
   402 		for j:= -1 to 1 do
   404 		for j:= -1 to 1 do
   403 			if (i <> 0) or (j <> 0) then
   405 			if (i <> 0) or (j <> 0) then
   417 		end;
   419 		end;
   418 	end;
   420 	end;
   419 Despeckle:= false
   421 Despeckle:= false
   420 end;
   422 end;
   421 
   423 
   422 procedure SweepDirty;
   424 function SweepDirty: boolean;
   423 var x, y, xx, yy: LongInt;
   425 var x, y, xx, yy: LongInt;
   424     updatedRow, updatedCell: boolean;
   426     updatedRow, updatedCell, Result: boolean;
   425 begin
   427 begin
       
   428 Result:= false;
       
   429 
   426 for y:= 0 to LAND_HEIGHT div 32 - 1 do
   430 for y:= 0 to LAND_HEIGHT div 32 - 1 do
   427 	begin
   431 	begin
   428 	updatedRow:= false;
   432 	updatedRow:= false;
   429 	
   433 	
   430 	for x:= 0 to LAND_WIDTH div 32 - 1 do
   434 	for x:= 0 to LAND_WIDTH div 32 - 1 do
   443 			until not updatedCell;
   447 			until not updatedCell;
   444 		LandDirty[y, x]:= 0;
   448 		LandDirty[y, x]:= 0;
   445 		end;
   449 		end;
   446 	
   450 	
   447 	if updatedRow then
   451 	if updatedRow then
       
   452 		begin
   448 		UpdateLandTexture(y * 32, 32);
   453 		UpdateLandTexture(y * 32, 32);
       
   454 		Result:= true
       
   455 		end
   449 	end;
   456 	end;
       
   457 
       
   458 SweepDirty:= Result
   450 end;
   459 end;
   451 
   460 
   452 end.
   461 end.