hedgewars/uLandObjects.pas
changeset 9768 08799c901a42
parent 9721 1833dadcebf0
child 9778 6166aa84a396
equal deleted inserted replaced
9767:17df4c8201f6 9768:08799c901a42
    24 
    24 
    25 procedure AddObjects();
    25 procedure AddObjects();
    26 procedure FreeLandObjects();
    26 procedure FreeLandObjects();
    27 procedure LoadThemeConfig;
    27 procedure LoadThemeConfig;
    28 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface); inline;
    28 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface); inline;
    29 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; extraFlags: Word);
    29 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; LandFlags: Word);
    30 procedure BlitImageUsingMask(cpX, cpY: Longword;  Image, Mask: PSDL_Surface);
    30 procedure BlitImageUsingMask(cpX, cpY: Longword;  Image, Mask: PSDL_Surface);
    31 procedure AddOnLandObjects(Surface: PSDL_Surface);
    31 procedure AddOnLandObjects(Surface: PSDL_Surface);
    32 procedure SetLand(var LandWord: Word; Pixel: LongWord); inline;
    32 procedure SetLand(var LandWord: Word; Pixel: LongWord); inline;
    33 
    33 
    34 implementation
    34 implementation
    93 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface); inline;
    93 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface); inline;
    94 begin
    94 begin
    95     BlitImageAndGenerateCollisionInfo(cpX, cpY, Width, Image, 0);
    95     BlitImageAndGenerateCollisionInfo(cpX, cpY, Width, Image, 0);
    96 end;
    96 end;
    97     
    97     
    98 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; extraFlags: Word);
    98 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; LandFlags: Word);
    99 var p: PLongwordArray;
    99 var p: PLongwordArray;
   100     x, y: Longword;
   100     x, y: Longword;
   101     bpp: LongInt;
   101     bpp: LongInt;
   102 begin
   102 begin
   103 WriteToConsole('Generating collision info... ');
   103 WriteToConsole('Generating collision info... ');
   126             else
   126             else
   127                 if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then 
   127                 if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then 
   128                     LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[x];
   128                     LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[x];
   129 
   129 
   130             if (Land[cpY + y, cpX + x] <= lfAllObjMask) and ((p^[x] and AMask) <> 0) then
   130             if (Land[cpY + y, cpX + x] <= lfAllObjMask) and ((p^[x] and AMask) <> 0) then
   131                 Land[cpY + y, cpX + x]:= lfObject or extraFlags
   131                 Land[cpY + y, cpX + x]:= lfObject or LandFlags
   132             end;
   132             end;
   133     p:= @(p^[Image^.pitch shr 2])
   133     p:= @(p^[Image^.pitch shr 2])
   134     end;
   134     end;
   135 
   135 
   136 if SDL_MustLock(Image) then
   136 if SDL_MustLock(Image) then
   275     tmpsurf:= LoadDataImageAltPath(ptCurrTheme, ptGraphics, 'Girder', ifCritical or ifTransparent or ifIgnoreCaps);
   275     tmpsurf:= LoadDataImageAltPath(ptCurrTheme, ptGraphics, 'Girder', ifCritical or ifTransparent or ifIgnoreCaps);
   276 
   276 
   277     rr.x:= x1;
   277     rr.x:= x1;
   278     while rr.x < x2 do
   278     while rr.x < x2 do
   279         begin
   279         begin
   280         // I should theme flag this. also snow...
   280         if cIce then 
   281         if (Theme = 'Snow') or (Theme = 'Christmas') then 
       
   282             BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf, lfIce)
   281             BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf, lfIce)
   283         else
   282         else
   284             BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf);
   283             BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf);
   285         inc(rr.x, tmpsurf^.w);
   284         inc(rr.x, tmpsurf^.w);
   286         end;
   285         end;
   704         end
   703         end
   705     else if key = 'flatten-flakes' then
   704     else if key = 'flatten-flakes' then
   706         cFlattenFlakes:= true
   705         cFlattenFlakes:= true
   707     else if key = 'flatten-clouds' then
   706     else if key = 'flatten-clouds' then
   708         cFlattenClouds:= true
   707         cFlattenClouds:= true
       
   708     else if key = 'ice' then
       
   709         cIce:= true
       
   710     else if key = 'snow' then
       
   711         cSnow:= true
   709     else if key = 'sd-water-top' then
   712     else if key = 'sd-water-top' then
   710         begin
   713         begin
   711         i:= Pos(',', s);
   714         i:= Pos(',', s);
   712         SDWaterColorArray[0].r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   715         SDWaterColorArray[0].r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   713         Delete(s, 1, i);
   716         Delete(s, 1, i);