hedgewars/uLand.pas
changeset 1181 3ae244bffef9
parent 1180 e56317fdf78d
child 1182 e2e13aa055c1
equal deleted inserted replaced
1180:e56317fdf78d 1181:3ae244bffef9
   566 end;
   566 end;
   567 
   567 
   568 procedure LoadMap;
   568 procedure LoadMap;
   569 var x, y: Longword;
   569 var x, y: Longword;
   570     p: PByteArray;
   570     p: PByteArray;
   571     LandSurface: PSDL_Surface;
   571     tmpsurf: PSDL_Surface;
   572 begin
   572 begin
   573 WriteLnToConsole('Loading land from file...');
   573 WriteLnToConsole('Loading land from file...');
   574 AddProgress;
   574 AddProgress;
   575 LandSurface:= LoadImage(Pathz[ptMapCurrent] + '/map', true, true, true);
   575 tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', true, true, true);
   576 TryDo((LandSurface^.w = 2048) and (LandSurface^.h = 1024), 'Map dimensions should be 2048x1024!', true);
   576 TryDo((tmpsurf^.w = 2048) and (tmpsurf^.h = 1024), 'Map dimensions should be 2048x1024!', true);
   577 
   577 
   578 if SDL_MustLock(LandSurface) then
   578 TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true);
   579 	SDLTry(SDL_LockSurface(LandSurface) >= 0, true);
   579 
   580 
   580 BlitImageAndGenerateCollisionInfo(0, 0, tmpsurf);
   581 TryDo(LandSurface^.format^.BytesPerPixel = 4, 'Map should be 32bit', true);
   581 SDL_FreeSurface(tmpsurf);
   582 
       
   583 for y:= 0 to 1023 do
       
   584 	begin
       
   585 	for x:= 0 to 2047 do
       
   586 		if (PLongword(@(p^[x * 4]))^ and $FF000000) <> 0 then Land[y, x]:= COLOR_LAND;
       
   587 	p:= @(p^[LandSurface^.pitch]);
       
   588 	end;
       
   589 
       
   590 if SDL_MustLock(LandSurface) then
       
   591 	SDL_UnlockSurface(LandSurface);
       
   592 
   582 
   593 UpdateLandTexture(0, 1023)
   583 UpdateLandTexture(0, 1023)
   594 end;
   584 end;
   595 
   585 
   596 procedure GenMap;
   586 procedure GenMap;