hedgewars/uLandObjects.pas
changeset 6112 7839a2ae90ae
parent 6081 537bbd5c1a62
child 6113 b3dfb796c3a5
equal deleted inserted replaced
6111:01b24f62471e 6112:7839a2ae90ae
    23 uses SDLh;
    23 uses SDLh;
    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);
    28 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; extraFlags: Word = 0);
    29 procedure AddOnLandObjects(Surface: PSDL_Surface);
    29 procedure AddOnLandObjects(Surface: PSDL_Surface);
    30 
    30 
    31 implementation
    31 implementation
    32 uses uStore, uConsts, uConsole, uRandom, uSound, GLunit,
    32 uses uStore, uConsts, uConsole, uRandom, uSound, GLunit,
    33      uTypes, uVariables, uUtils, uDebug, sysutils;
    33      uTypes, uVariables, uUtils, uDebug, sysutils;
    64     RectCount: Longword;
    64     RectCount: Longword;
    65     ThemeObjects: TThemeObjects;
    65     ThemeObjects: TThemeObjects;
    66     SprayObjects: TSprayObjects;
    66     SprayObjects: TSprayObjects;
    67 
    67 
    68 
    68 
    69 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface);
    69 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; extraFlags: Word = 0);
    70 var p: PLongwordArray;
    70 var p: PLongwordArray;
    71     x, y: Longword;
    71     x, y: Longword;
    72     bpp: LongInt;
    72     bpp: LongInt;
    73 begin
    73 begin
    74 WriteToConsole('Generating collision info... ');
    74 WriteToConsole('Generating collision info... ');
    94             end
    94             end
    95             else
    95             else
    96                 if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then 
    96                 if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then 
    97                     LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[x];
    97                     LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[x];
    98 
    98 
       
    99         Land[cpY + y, cpX + x]:= Land[cpY + y, cpX + x] or extraFlags;
       
   100 
    99         if ((Land[cpY + y, cpX + x] and $FF00) = 0) and ((p^[x] and AMask) <> 0) then
   101         if ((Land[cpY + y, cpX + x] and $FF00) = 0) and ((p^[x] and AMask) <> 0) then
   100             begin
   102             begin
   101             Land[cpY + y, cpX + x]:= lfObject;
   103             Land[cpY + y, cpX + x]:= lfObject;
   102             // For testing only. Intent is to flag this on objects with masks, or use it for an ice ray gun
       
   103             if (Theme = 'Snow') or (Theme = 'Christmas') then Land[cpY + y, cpX + x]:= Land[cpY + y, cpX + x] or lfIce
       
   104             end;
   104             end;
   105         end;
   105         end;
   106     p:= @(p^[Image^.pitch shr 2])
   106     p:= @(p^[Image^.pitch shr 2])
   107     end;
   107     end;
   108 
   108 
   206     if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptGraphics] + '/Girder', ifCritical or ifTransparent or ifIgnoreCaps);
   206     if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptGraphics] + '/Girder', ifCritical or ifTransparent or ifIgnoreCaps);
   207 
   207 
   208     rr.x:= x1;
   208     rr.x:= x1;
   209     while rr.x < x2 do
   209     while rr.x < x2 do
   210         begin
   210         begin
   211         BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf);
   211         // For testing only. Intent is to flag this on objects with masks, or use it for an ice ray gun
       
   212         if (Theme = 'Snow') or (Theme = 'Christmas') then 
       
   213             BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf, lfIce)
       
   214         else
       
   215             BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf);
   212         inc(rr.x, tmpsurf^.w);
   216         inc(rr.x, tmpsurf^.w);
   213         end;
   217         end;
   214     SDL_FreeSurface(tmpsurf);
   218     SDL_FreeSurface(tmpsurf);
   215 
   219 
   216     AddRect(x1 - 8, y - 32, x2 - x1 + 16, 80);
   220     AddRect(x1 - 8, y - 32, x2 - x1 + 16, 80);