hedgewars/uLandGraphics.pas
changeset 4886 e3e5362a308e
parent 4791 458d9854c679
child 4976 088d40d8aba2
equal deleted inserted replaced
4884:b2006a9f0fbc 4886:e3e5362a308e
    36 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
    36 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
    37 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
    37 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
    38 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
    38 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
    39 function  LandBackPixel(x, y: LongInt): LongWord;
    39 function  LandBackPixel(x, y: LongInt): LongWord;
    40 
    40 
    41 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
    41 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean;
    42 
    42 
    43 implementation
    43 implementation
    44 uses SDLh, uLandTexture, uVariables, uUtils, uDebug;
    44 uses SDLh, uLandTexture, uVariables, uUtils, uDebug;
    45 
    45 
    46 function addBgColor(OldColor, NewColor: LongWord): LongWord;
    46 function addBgColor(OldColor, NewColor: LongWord): LongWord;
   617 ddy:= Min(stY + HalfWidth * 2 + 4 + abs(hwRound(dY * ticks)), LAND_HEIGHT) - ty;
   617 ddy:= Min(stY + HalfWidth * 2 + 4 + abs(hwRound(dY * ticks)), LAND_HEIGHT) - ty;
   618 
   618 
   619 UpdateLandTexture(tx, ddx, ty, ddy)
   619 UpdateLandTexture(tx, ddx, ty, ddy)
   620 end;
   620 end;
   621 
   621 
   622 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
   622 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean;
   623 var X, Y, bpp, h, w, row, col, numFramesFirstCol: LongInt;
   623 var X, Y, bpp, h, w, row, col, numFramesFirstCol: LongInt;
   624     p: PByteArray;
   624     p: PByteArray;
   625     Image: PSDL_Surface;
   625     Image: PSDL_Surface;
   626 begin
   626 begin
   627 numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height;
   627 numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height;
   673      4: for y:= 0 to Pred(h) do
   673      4: for y:= 0 to Pred(h) do
   674             begin
   674             begin
   675             for x:= 0 to Pred(w) do
   675             for x:= 0 to Pred(w) do
   676                 if PLongword(@(p^[x * 4]))^ <> 0 then
   676                 if PLongword(@(p^[x * 4]))^ <> 0 then
   677                    begin
   677                    begin
   678                    Land[cpY + y, cpX + x]:= lfObject;
   678                    if indestructible then
       
   679                        Land[cpY + y, cpX + x]:= lfIndestructible
       
   680                    else
       
   681                        Land[cpY + y, cpX + x]:= lfObject;
   679                    if (cReducedQuality and rqBlurryLand) = 0 then
   682                    if (cReducedQuality and rqBlurryLand) = 0 then
   680                        LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^
   683                        LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^
   681                    else
   684                    else
   682                        LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= PLongword(@(p^[x * 4]))^
   685                        LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= PLongword(@(p^[x * 4]))^
   683                    end;
   686                    end;