hedgewars/uLandObjects.pas
changeset 1182 e2e13aa055c1
parent 1181 3ae244bffef9
child 1183 540cea859395
equal deleted inserted replaced
1181:3ae244bffef9 1182:e2e13aa055c1
    60     ThemeObjects: TThemeObjects;
    60     ThemeObjects: TThemeObjects;
    61     SprayObjects: TSprayObjects;
    61     SprayObjects: TSprayObjects;
    62 
    62 
    63 
    63 
    64 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY: Longword; Image: PSDL_Surface);
    64 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY: Longword; Image: PSDL_Surface);
    65 var p: PByteArray;
    65 var p: PLongwordArray;
    66     x, y: Longword;
    66     x, y: Longword;
    67     bpp: LongInt;
    67     bpp: LongInt;
    68     r: TSDL_Rect;
    68     r: TSDL_Rect;
    69 begin
    69 begin
    70 r.x:= cpX;
    70 r.x:= cpX;
    74 if SDL_MustLock(Image) then
    74 if SDL_MustLock(Image) then
    75    SDLTry(SDL_LockSurface(Image) >= 0, true);
    75    SDLTry(SDL_LockSurface(Image) >= 0, true);
    76 
    76 
    77 bpp:= Image^.format^.BytesPerPixel;
    77 bpp:= Image^.format^.BytesPerPixel;
    78 TryDo(bpp = 4, 'Land object should be 32bit', true);
    78 TryDo(bpp = 4, 'Land object should be 32bit', true);
       
    79 
    79 p:= Image^.pixels;
    80 p:= Image^.pixels;
    80 
       
    81 for y:= 0 to Pred(Image^.h) do
    81 for y:= 0 to Pred(Image^.h) do
    82 	begin
    82 	begin
    83 	for x:= 0 to Pred(Image^.w) do
    83 	for x:= 0 to Pred(Image^.w) do
    84 		if LandPixels[cpY + y, cpX + x] = 0 then
    84 		if LandPixels[cpY + y, cpX + x] = 0 then
    85 			begin
    85 			begin
    86 			LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^;
    86 			LandPixels[cpY + y, cpX + x]:= p^[x];
    87 			if (PLongword(@(p^[x * 4]))^ and $FF000000) <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND;
    87 			if (p^[x] and $FF000000) <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND;
    88 			end;
    88 			end;
    89 	p:= @(p^[Image^.pitch]);
    89 	p:= @(p^[Image^.pitch div 4]);
    90 	end;
    90 	end;
    91 
    91 
    92 if SDL_MustLock(Image) then
    92 if SDL_MustLock(Image) then
    93    SDL_UnlockSurface(Image);
    93    SDL_UnlockSurface(Image);
    94 WriteLnToConsole(msgOK)
    94 WriteLnToConsole(msgOK)