hedgewars/uLand.pas
changeset 11705 4b2179d9516c
parent 11650 573e79db6688
child 11706 863e1a75ec99
equal deleted inserted replaced
11704:1694b379c83f 11705:4b2179d9516c
   348     AddProgress();
   348     AddProgress();
   349 end;
   349 end;
   350 
   350 
   351 procedure MakeFortsMap;
   351 procedure MakeFortsMap;
   352 var tmpsurf: PSDL_Surface;
   352 var tmpsurf: PSDL_Surface;
   353 begin
   353     i: integer;
   354 ResizeLand(4096,2048);
   354     mirror: boolean;
   355 MaxHedgehogs:= 32;
   355 const sectionWidth = 1024 + 300;
       
   356 begin
       
   357 // figure out how much space we need
       
   358 playWidth:= sectionWidth * ClansCount;
       
   359 
       
   360 // note: LAND_WIDTH might be bigger than specified below (rounded to next power of 2)
       
   361 ResizeLand(playWidth, 2048);
       
   362 
   356 // For now, defining a fort is playable area as 3072x1200 - there are no tall forts.  The extra height is to avoid triggering border with current code, also if user turns on a border, it will give a bit more maneuvering room.
   363 // For now, defining a fort is playable area as 3072x1200 - there are no tall forts.  The extra height is to avoid triggering border with current code, also if user turns on a border, it will give a bit more maneuvering room.
   357 playHeight:= 1200;
   364 playHeight:= 1200;
   358 playWidth:= 2560;
   365 
   359 leftX:= (LAND_WIDTH - playWidth) div 2;
   366 // center playable area in land array
       
   367 leftX:= ((LAND_WIDTH - playWidth) div 2);
   360 rightX:= ((playWidth + (LAND_WIDTH - playWidth) div 2) - 1);
   368 rightX:= ((playWidth + (LAND_WIDTH - playWidth) div 2) - 1);
   361 topY:= LAND_HEIGHT - playHeight;
   369 topY:= LAND_HEIGHT - playHeight;
   362 
   370 
   363 WriteLnToConsole('Generating forts land...');
   371 WriteLnToConsole('Generating forts land...');
   364 
   372 
   365 tmpsurf:= LoadDataImage(ptForts, ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
   373 for i := 0 to ClansCount - 1 do
   366 BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
   374     begin
   367 SDL_FreeSurface(tmpsurf);
   375 
   368 
   376     // face in random direction
   369 // not critical because if no R we can fallback to mirrored L
   377     mirror:= (GetRandom(2) = 0);
   370 tmpsurf:= LoadDataImage(ptForts, ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps);
   378     // make first/last fort face inwards
   371 // fallback
   379     if WorldEdge <> weWrap then
   372 if tmpsurf = nil then
   380         mirror:= (i <> 0) and (mirror or (i = ClansCount));
   373     begin
   381 
   374     tmpsurf:= LoadDataImage(ptForts, ClansArray[1]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
   382     if mirror then
   375     BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf, 0, true);
   383         begin
   376     end
   384         // not critical because if no R we can fallback to mirrored L
   377 else
   385         tmpsurf:= LoadDataImage(ptForts, ClansArray[i]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps);
   378     BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
   386         // fallback
   379 SDL_FreeSurface(tmpsurf);
   387         if tmpsurf = nil then
       
   388             begin
       
   389             tmpsurf:= LoadDataImage(ptForts, ClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
       
   390             BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf, 0, true);
       
   391             end
       
   392         else
       
   393             BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
       
   394         SDL_FreeSurface(tmpsurf);
       
   395         end
       
   396     else
       
   397         begin
       
   398         tmpsurf:= LoadDataImage(ptForts, ClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
       
   399         BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
       
   400         SDL_FreeSurface(tmpsurf);
       
   401         end;
       
   402 
       
   403     end;
   380 end;
   404 end;
   381 
   405 
   382 procedure LoadMapConfig;
   406 procedure LoadMapConfig;
   383 var f: PFSFile;
   407 var f: PFSFile;
   384     s: shortstring;
   408     s: shortstring;