hedgewars/uLandGraphics.pas
changeset 6077 d8fa5a85d24f
parent 6011 519f8a58c021
child 6081 537bbd5c1a62
equal deleted inserted replaced
6076:e1b4771f6472 6077:d8fa5a85d24f
   645 
   645 
   646 UpdateLandTexture(tx, ddx, ty, ddy)
   646 UpdateLandTexture(tx, ddx, ty, ddy)
   647 end;
   647 end;
   648 
   648 
   649 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean;
   649 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean;
   650 var X, Y, bpp, h, w, row, col, numFramesFirstCol: LongInt;
   650 var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt;
   651     p: PByteArray;
   651     p: PByteArray;
   652     Image: PSDL_Surface;
   652     Image: PSDL_Surface;
   653 begin
   653 begin
   654 numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height;
   654 numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height;
   655 
   655 
   700      4: for y:= 0 to Pred(h) do
   700      4: for y:= 0 to Pred(h) do
   701             begin
   701             begin
   702             for x:= 0 to Pred(w) do
   702             for x:= 0 to Pred(w) do
   703                 if PLongword(@(p^[x * 4]))^ <> 0 then
   703                 if PLongword(@(p^[x * 4]))^ <> 0 then
   704                    begin
   704                    begin
       
   705                    if (cReducedQuality and rqBlurryLand) = 0 then
       
   706                        begin
       
   707                        gX:= cpX + x;
       
   708                        gY:= cpY + y;
       
   709                        end
       
   710                    else
       
   711                        begin
       
   712                        gX:= (cpX + x) div 2;
       
   713                        gY:= (cpY + y) div 2;
       
   714                        end;
   705                    if indestructible then
   715                    if indestructible then
   706                        Land[cpY + y, cpX + x]:= lfIndestructible
   716                        Land[cpY + y, cpX + x]:= lfIndestructible
       
   717                    else if (LandPixels[gY, gX] and AMask) shr AShift = 255 then  // This test assumes lfBasic and lfObject differ only graphically
       
   718                        Land[cpY + y, cpX + x]:= lfBasic
   707                    else
   719                    else
   708                        Land[cpY + y, cpX + x]:= lfObject;
   720                        Land[cpY + y, cpX + x]:= lfObject;
   709                    if (cReducedQuality and rqBlurryLand) = 0 then
   721                    LandPixels[gY, gX]:= PLongword(@(p^[x * 4]))^
   710                        LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^
       
   711                    else
       
   712                        LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= PLongword(@(p^[x * 4]))^
       
   713                    end;
   722                    end;
   714             p:= @(p^[Image^.pitch]);
   723             p:= @(p^[Image^.pitch]);
   715             end;
   724             end;
   716      end;
   725      end;
   717 if SDL_MustLock(Image) then
   726 if SDL_MustLock(Image) then