hedgewars/uLand.pas
changeset 2647 0e1208e92dfe
parent 2619 bc2786a00fb8
child 2665 50b4e544c163
equal deleted inserted replaced
2646:6a1185633872 2647:0e1208e92dfe
    36      LandPixels: TLandArray;
    36      LandPixels: TLandArray;
    37      LandDirty: TDirtyTag;
    37      LandDirty: TDirtyTag;
    38      hasBorder: boolean; 
    38      hasBorder: boolean; 
    39      hasGirders: boolean;  
    39      hasGirders: boolean;  
    40      playHeight, playWidth, leftX, rightX, topY, MaxHedgehogs: Longword;  // idea is that a template can specify height/width.  Or, a map, a height/width by the dimensions of the image.  If the map has pixels near top of image, it triggers border.
    40      playHeight, playWidth, leftX, rightX, topY, MaxHedgehogs: Longword;  // idea is that a template can specify height/width.  Or, a map, a height/width by the dimensions of the image.  If the map has pixels near top of image, it triggers border.
       
    41 	 LandBackSurface: PSDL_Surface = nil;
    41 
    42 
    42 procedure GenMap;
    43 procedure GenMap;
    43 function  GenPreview: TPreview;
    44 function  GenPreview: TPreview;
    44 procedure CheckLandDigest(s: shortstring);
    45 procedure CheckLandDigest(s: shortstring);
       
    46 function LandBackPixel(x, y: LongInt): LongWord;
    45 
    47 
    46 implementation
    48 implementation
    47 uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, uSHA, uIO, uAmmos, uLandTexture;
    49 uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, uSHA, uIO, uAmmos, uLandTexture;
    48 
    50 
    49 type TPixAr = record
    51 type TPixAr = record
   305                end;
   307                end;
   306             end;
   308             end;
   307       end;
   309       end;
   308 end;
   310 end;
   309 
   311 
       
   312 function LandBackPixel(x, y: LongInt): LongWord;
       
   313 var p: PLongWordArray;
       
   314 begin
       
   315 	if LandBackSurface = nil then
       
   316 		LandBackPixel:= 0
       
   317 	else
       
   318 		begin
       
   319 		p:= LandBackSurface^.pixels;
       
   320 		LandBackPixel:= p^[LandBackSurface^.w * (y mod LandBackSurface^.h) + (x mod LandBackSurface^.w)];// or $FF000000;
       
   321 		end
       
   322 end;
       
   323 
   310 procedure ColorizeLand(Surface: PSDL_Surface);
   324 procedure ColorizeLand(Surface: PSDL_Surface);
   311 var tmpsurf: PSDL_Surface;
   325 var tmpsurf: PSDL_Surface;
   312     r, rr: TSDL_Rect;
   326     r, rr: TSDL_Rect;
   313     x, yd, yu: LongInt;
   327     x, yd, yu: LongInt;
   314 begin
   328 begin
   323 		inc(r.x, tmpsurf^.w)
   337 		inc(r.x, tmpsurf^.w)
   324 		end;
   338 		end;
   325 	inc(r.y, tmpsurf^.h)
   339 	inc(r.y, tmpsurf^.h)
   326 	end;
   340 	end;
   327 SDL_FreeSurface(tmpsurf);
   341 SDL_FreeSurface(tmpsurf);
       
   342 
       
   343 LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
   328 
   344 
   329 tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent);
   345 tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent);
   330 for x:= 0 to LAND_WIDTH - 1 do
   346 for x:= 0 to LAND_WIDTH - 1 do
   331 	begin
   347 	begin
   332 	yd:= LAND_HEIGHT - 1;
   348 	yd:= LAND_HEIGHT - 1;
   833 GenPreview:= Preview
   849 GenPreview:= Preview
   834 end;
   850 end;
   835 
   851 
   836 initialization
   852 initialization
   837 
   853 
       
   854 finalization
       
   855 if LandBackSurface <> nil then
       
   856 	SDL_FreeSurface(LandBackSurface);
   838 end.
   857 end.