hedgewars/uLandGraphics.pas
changeset 10903 c9a0cdee4267
parent 10901 fbf6fbe66092
child 10909 594f59bd1751
equal deleted inserted replaced
10901:fbf6fbe66092 10903:c9a0cdee4267
    49 procedure DrawIceBreak(x, y, iceRadius, iceHeight: Longint);
    49 procedure DrawIceBreak(x, y, iceRadius, iceHeight: Longint);
    50 function TryPlaceOnLandSimple(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean; inline;
    50 function TryPlaceOnLandSimple(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean; inline;
    51 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean; inline;
    51 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean; inline;
    52 function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; Tint: LongWord; Behind, flipHoriz, flipVert: boolean): boolean; inline;
    52 function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; Tint: LongWord; Behind, flipHoriz, flipVert: boolean): boolean; inline;
    53 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force, behind, flipHoriz, flipVert: boolean; LandFlags: Word; Tint: LongWord): boolean;
    53 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force, behind, flipHoriz, flipVert: boolean; LandFlags: Word; Tint: LongWord): boolean;
    54 procedure EraseLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; eraseOnLFMatch, flipHoriz, flipVert: boolean);
    54 procedure EraseLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert: boolean);
    55 function GetPlaceCollisionTex(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): PTexture;
    55 function GetPlaceCollisionTex(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): PTexture;
    56 
    56 
    57 implementation
    57 implementation
    58 uses SDLh, uLandTexture, uTextures, uVariables, uUtils, uDebug, uScript;
    58 uses SDLh, uLandTexture, uTextures, uVariables, uUtils, uDebug, uScript;
    59 
    59 
   814 else if Obj = sprAmRubber then
   814 else if Obj = sprAmRubber then
   815     ScriptCall('onRubberPlacement', frame, cpX + w div 2, cpY + h div 2);
   815     ScriptCall('onRubberPlacement', frame, cpX + w div 2, cpY + h div 2);
   816 
   816 
   817 end;
   817 end;
   818 
   818 
   819 procedure EraseLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; eraseOnLFMatch, flipHoriz, flipVert: boolean);
   819 procedure EraseLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert: boolean);
   820 var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt;
   820 var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt;
   821     p: PByteArray;
   821     p: PByteArray;
   822     Image: PSDL_Surface;
   822     Image: PSDL_Surface;
   823     pixel: LongWord;
       
   824 begin
   823 begin
   825 numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height;
   824 numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height;
   826 
   825 
   827 TryDo(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true);
   826 TryDo(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true);
   828 
   827 
   876                     gY:= (cpY + y) div 2;
   875                     gY:= (cpY + y) div 2;
   877                     end;
   876                     end;
   878 		        if (not eraseOnLFMatch or (Land[cpY + y, cpX + x] and LandFlags <> 0)) and
   877 		        if (not eraseOnLFMatch or (Land[cpY + y, cpX + x] and LandFlags <> 0)) and
   879                     (PLongword(@(p^[x * 4]))^ and AMask <> 0) then
   878                     (PLongword(@(p^[x * 4]))^ and AMask <> 0) then
   880                     begin
   879                     begin
   881                     LandPixels[gY, gX]:= 0;
   880                     if not onlyEraseLF then
   882                     Land[cpY + y, cpX + x]:= 0
   881                         begin
       
   882                         LandPixels[gY, gX]:= 0;
       
   883                         Land[cpY + y, cpX + x]:= 0
       
   884                         end
       
   885                     else Land[cpY + y, cpX + x]:= Land[cpY + y, cpX + x] and not LandFlags
   883                     end
   886                     end
   884                 end;
   887                 end;
   885         p:= PByteArray(@(p^[Image^.pitch]));
   888         p:= PByteArray(@(p^[Image^.pitch]));
   886         end;
   889         end;
   887     end;
   890     end;