hedgewars/uLandObjects.pas
branchsdl2transition
changeset 9798 f2b18754742f
parent 9688 98024c99e58d
parent 9778 6166aa84a396
child 11362 ed5a6478e710
equal deleted inserted replaced
9711:7d0329f37181 9798:f2b18754742f
    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                 begin
   131                 Land[cpY + y, cpX + x]:= lfObject or LandFlags
   132                 Land[cpY + y, cpX + x]:= lfObject;
       
   133                 Land[cpY + y, cpX + x]:= Land[cpY + y, cpX + x] or extraFlags
       
   134                 end;
       
   135             end;
   132             end;
   136     p:= @(p^[Image^.pitch shr 2])
   133     p:= @(p^[Image^.pitch shr 2])
   137     end;
   134     end;
   138 
   135 
   139 if SDL_MustLock(Image) then
   136 if SDL_MustLock(Image) then
   278     tmpsurf:= LoadDataImageAltPath(ptCurrTheme, ptGraphics, 'Girder', ifCritical or ifTransparent or ifIgnoreCaps);
   275     tmpsurf:= LoadDataImageAltPath(ptCurrTheme, ptGraphics, 'Girder', ifCritical or ifTransparent or ifIgnoreCaps);
   279 
   276 
   280     rr.x:= x1;
   277     rr.x:= x1;
   281     while rr.x < x2 do
   278     while rr.x < x2 do
   282         begin
   279         begin
   283         // For testing only. Intent is to flag this on objects with masks, or use it for an ice ray gun
   280         if cIce then 
   284         if (Theme = 'Snow') or (Theme = 'Christmas') then 
       
   285             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)
   286         else
   282         else
   287             BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf);
   283             BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf);
   288         inc(rr.x, tmpsurf^.w);
   284         inc(rr.x, tmpsurf^.w);
   289         end;
   285         end;
   498     end;
   494     end;
   499 
   495 
   500 s:= cPathz[ptCurrTheme] + '/' + cThemeCFGFilename;
   496 s:= cPathz[ptCurrTheme] + '/' + cThemeCFGFilename;
   501 WriteLnToConsole('Reading objects info...');
   497 WriteLnToConsole('Reading objects info...');
   502 f:= pfsOpenRead(s);
   498 f:= pfsOpenRead(s);
   503 TryDo(f <> nil, 'Bad data or cannot access file ' + cThemeCFGFilename, true);
   499 TryDo(f <> nil, 'Bad data or cannot access file ' + s, true);
   504 
   500 
   505 ThemeObjects.Count:= 0;
   501 ThemeObjects.Count:= 0;
   506 SprayObjects.Count:= 0;
   502 SprayObjects.Count:= 0;
   507 
   503 
   508 while not pfsEOF(f) do
   504 while not pfsEOF(f) do
   708         end
   704         end
   709     else if key = 'flatten-flakes' then
   705     else if key = 'flatten-flakes' then
   710         cFlattenFlakes:= true
   706         cFlattenFlakes:= true
   711     else if key = 'flatten-clouds' then
   707     else if key = 'flatten-clouds' then
   712         cFlattenClouds:= true
   708         cFlattenClouds:= true
       
   709     else if key = 'ice' then
       
   710         cIce:= true
       
   711     else if key = 'snow' then
       
   712         cSnow:= true
   713     else if key = 'sd-water-top' then
   713     else if key = 'sd-water-top' then
   714         begin
   714         begin
   715         i:= Pos(',', s);
   715         i:= Pos(',', s);
   716         SDWaterColorArray[0].r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   716         SDWaterColorArray[0].r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   717         Delete(s, 1, i);
   717         Delete(s, 1, i);