hedgewars/uLand.pas
changeset 15158 4744d7b78c75
parent 15144 59c595191eba
child 15171 2765731b378b
equal deleted inserted replaced
15157:490bd70dac6e 15158:4744d7b78c75
    47         PrettifyAlpha2D(LandPixels, LAND_HEIGHT, LAND_WIDTH);
    47         PrettifyAlpha2D(LandPixels, LAND_HEIGHT, LAND_WIDTH);
    48 end;
    48 end;
    49 
    49 
    50 procedure DrawBorderFromImage(Surface: PSDL_Surface);
    50 procedure DrawBorderFromImage(Surface: PSDL_Surface);
    51 var tmpsurf: PSDL_Surface;
    51 var tmpsurf: PSDL_Surface;
    52     //r, rr: TSDL_Rect;
       
    53     x, yd, yu: LongInt;
    52     x, yd, yu: LongInt;
    54     targetMask: Word;
    53     targetMask: Word;
    55 begin
    54 begin
    56     tmpsurf:= LoadDataImage(ptCurrTheme, 'Border', ifCritical or ifIgnoreCaps or ifColorKey);
    55     tmpsurf:= LoadDataImage(ptCurrTheme, 'Border', ifCritical or ifIgnoreCaps or ifColorKey);
    57 
    56 
   267         begin
   266         begin
   268         r.x:= 0;
   267         r.x:= 0;
   269         while r.x < LAND_WIDTH do
   268         while r.x < LAND_WIDTH do
   270             begin
   269             begin
   271             copyToXY(tmpsurf, Surface, r.x, r.y);
   270             copyToXY(tmpsurf, Surface, r.x, r.y);
   272             //SDL_UpperBlit(tmpsurf, nil, Surface, @r);
       
   273             inc(r.x, tmpsurf^.w)
   271             inc(r.x, tmpsurf^.w)
   274             end;
   272             end;
   275         inc(y, tmpsurf^.h);
   273         inc(y, tmpsurf^.h);
   276         r.y:= y
   274         r.y:= y
   277         end;
   275         end;
   364     for x:= 0 to LAND_WIDTH - 1 do
   362     for x:= 0 to LAND_WIDTH - 1 do
   365     if Land[y, x] <> 0 then
   363     if Land[y, x] <> 0 then
   366         if (cReducedQuality and rqBlurryLand) = 0 then
   364         if (cReducedQuality and rqBlurryLand) = 0 then
   367             LandPixels[y, x]:= p^[x]// or AMask
   365             LandPixels[y, x]:= p^[x]// or AMask
   368         else
   366         else
   369             LandPixels[y div 2, x div 2]:= p^[x];// or AMask;
   367             LandPixels[y div 2, x div 2]:= p^[x];
   370 
   368 
   371     p:= PLongwordArray(@(p^[Surface^.pitch div 4]));
   369     p:= PLongwordArray(@(p^[Surface^.pitch div 4]));
   372     end;
   370     end;
   373 
   371 
   374 if SDL_MustLock(Surface) then
   372 if SDL_MustLock(Surface) then
   780                     hasBorder:= true;
   778                     hasBorder:= true;
   781                     break;
   779                     break;
   782                     end;
   780                     end;
   783                 end;
   781                 end;
   784 
   782 
       
   783 // Indestructible map border (top, left, right)
   785 if hasBorder then
   784 if hasBorder then
   786     begin
   785     begin
       
   786     // Make land beyond the border indestructible
   787     if WorldEdge = weNone then
   787     if WorldEdge = weNone then
   788         begin
   788         begin
   789         for y:= 0 to LAND_HEIGHT - 1 do
   789         for y:= 0 to LAND_HEIGHT - 1 do
   790             for x:= 0 to LAND_WIDTH - 1 do
   790             for x:= 0 to LAND_WIDTH - 1 do
   791                 if (y < LongWord(topY)) or (x < LongWord(leftX)) or (x > LongWord(rightX)) then
   791                 if (y < LongWord(topY)) or (x < LongWord(leftX)) or (x > LongWord(rightX)) then
   795         begin
   795         begin
   796         for y:= 0 to LongWord(topY - 1) do
   796         for y:= 0 to LongWord(topY - 1) do
   797             for x:= 0 to LAND_WIDTH - 1 do
   797             for x:= 0 to LAND_WIDTH - 1 do
   798                 Land[y, x]:= lfIndestructible;
   798                 Land[y, x]:= lfIndestructible;
   799         end;
   799         end;
   800     // experiment hardcoding cave
   800     // Render map border
   801     // also try basing cave dimensions on map/template dimensions, if they exist
   801     for w:= 0 to (cBorderWidth-1) do
   802     for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade
   802         begin
   803         begin
   803         // Left and right border
   804         if (WorldEdge <> weBounce) and (WorldEdge <> weWrap) then
   804         if (WorldEdge <> weBounce) and (WorldEdge <> weWrap) then
   805             for y:= LongWord(topY) to LAND_HEIGHT - 1 do
   805             for y:= LongWord(topY) to LAND_HEIGHT - 1 do
   806                     begin
   806                     begin
       
   807                     // set land flags
   807                     Land[y, leftX + w]:= lfIndestructible;
   808                     Land[y, leftX + w]:= lfIndestructible;
   808                     Land[y, rightX - w]:= lfIndestructible;
   809                     Land[y, rightX - w]:= lfIndestructible;
       
   810 
       
   811                     // paint black and yellow stripes
   809                     if (y + leftX + w) mod 32 < 16 then
   812                     if (y + leftX + w) mod 32 < 16 then
   810                         c:= AMask
   813                         c:= AMask // black
   811                     else
   814                     else
   812                         c:= AMask or RMask or GMask; // FF00FFFF
   815                         c:= AMask or RMask or GMask; // yellow
   813                     if (y + rightX - w) mod 32 < 16 then
   816                     if (y + rightX - w) mod 32 < 16 then
   814                         c2:= AMask
   817                         c2:= AMask // black
   815                     else
   818                     else
   816                         c2:= AMask or RMask or GMask; // FF00FFFF
   819                         c2:= AMask or RMask or GMask; // yellow
   817 
   820 
   818                     if (cReducedQuality and rqBlurryLand) = 0 then
   821                     if (cReducedQuality and rqBlurryLand) = 0 then
   819                         begin
   822                         begin
   820                         LandPixels[y, leftX + w]:= c;
   823                         LandPixels[y, leftX + w]:= c;
   821                         LandPixels[y, rightX - w]:= c2;
   824                         LandPixels[y, rightX - w]:= c2;
   825                         LandPixels[y div 2, (leftX + w) div 2]:= c;
   828                         LandPixels[y div 2, (leftX + w) div 2]:= c;
   826                         LandPixels[y div 2, (rightX - w) div 2]:= c2;
   829                         LandPixels[y div 2, (rightX - w) div 2]:= c2;
   827                         end;
   830                         end;
   828                     end;
   831                     end;
   829 
   832 
       
   833         // Top border
   830         for x:= LongWord(leftX) to LongWord(rightX) do
   834         for x:= LongWord(leftX) to LongWord(rightX) do
   831             begin
   835             begin
   832             Land[topY + w, x]:= lfIndestructible;
   836             Land[topY + w, x]:= lfIndestructible;
   833             if (topY + x + w) mod 32 < 16 then
   837             if (topY + x + w) mod 32 < 16 then
   834                 c:= AMask
   838                 c:= AMask // black
   835             else
   839             else
   836                 c:= AMask or RMask or GMask; // FF00FFFF
   840                 c:= AMask or RMask or GMask; // yellow
   837 
   841 
   838             if (cReducedQuality and rqBlurryLand) = 0 then
   842             if (cReducedQuality and rqBlurryLand) = 0 then
   839                 LandPixels[topY + w, x]:= c
   843                 LandPixels[topY + w, x]:= c
   840             else
   844             else
   841                 LandPixels[(topY + w) div 2, x div 2]:= c;
   845                 LandPixels[(topY + w) div 2, x div 2]:= c;
   842             end;
   846             end;
   843         end;
   847         end;
   844     end;
   848     end;
   845 
   849 
       
   850 // Bottom border
   846 if (GameFlags and gfBottomBorder) <> 0 then
   851 if (GameFlags and gfBottomBorder) <> 0 then
   847     DrawBottomBorder;
   852     DrawBottomBorder;
   848 
   853 
   849 if (GameFlags and gfDisableGirders) <> 0 then
   854 if (GameFlags and gfDisableGirders) <> 0 then
   850     hasGirders:= false;
   855     hasGirders:= false;