hedgewars/uLandTexture.pas
changeset 3509 d72c2219595d
parent 3491 4619b1ae99b5
child 3513 f589230fa21b
equal deleted inserted replaced
3507:2e40893e6034 3509:d72c2219595d
    29 implementation
    29 implementation
    30 uses uMisc, uLand, uStore, uConsts, GLunit;
    30 uses uMisc, uLand, uStore, uConsts, GLunit;
    31 
    31 
    32 
    32 
    33 const TEXSIZE = 256;
    33 const TEXSIZE = 256;
       
    34 {$IFDEF DOWNSCALE}
       
    35     LANDTEXARW = (LAND_WIDTH div TEXSIZE) div 2;
       
    36     LANDTEXARH = (LAND_HEIGHT div TEXSIZE) div 2;
       
    37 {$ELSE}
    34     LANDTEXARW = LAND_WIDTH div TEXSIZE;
    38     LANDTEXARW = LAND_WIDTH div TEXSIZE;
    35     LANDTEXARH = LAND_HEIGHT div TEXSIZE;
    39     LANDTEXARH = LAND_HEIGHT div TEXSIZE;
       
    40 {$ENDIF}
    36 
    41 
    37 var
    42 var
    38     LandTextures: array[0..LANDTEXARW - 1, 0..LANDTEXARH - 1] of
    43     LandTextures: array[0..LANDTEXARW - 1, 0..LANDTEXARH - 1] of
    39             record
    44             record
    40             shouldUpdate: boolean;
    45             shouldUpdate: boolean;
    69 TryDo((X >= 0) and (X < LAND_WIDTH), 'UpdateLandTexture: wrong X parameter', true);
    74 TryDo((X >= 0) and (X < LAND_WIDTH), 'UpdateLandTexture: wrong X parameter', true);
    70 TryDo(X + Width <= LAND_WIDTH, 'UpdateLandTexture: wrong Width parameter', true);
    75 TryDo(X + Width <= LAND_WIDTH, 'UpdateLandTexture: wrong Width parameter', true);
    71 TryDo((Y >= 0) and (Y < LAND_HEIGHT), 'UpdateLandTexture: wrong Y parameter', true);
    76 TryDo((Y >= 0) and (Y < LAND_HEIGHT), 'UpdateLandTexture: wrong Y parameter', true);
    72 TryDo(Y + Height <= LAND_HEIGHT, 'UpdateLandTexture: wrong Height parameter', true);
    77 TryDo(Y + Height <= LAND_HEIGHT, 'UpdateLandTexture: wrong Height parameter', true);
    73 
    78 
       
    79 {$IFDEF DOWNSCALE}
       
    80 for ty:= (Y div TEXSIZE) div 2 to ((Y + Height - 1) div TEXSIZE) div 2 do
       
    81     for tx:= (X div TEXSIZE) div 2 to ((X + Width - 1) div TEXSIZE) div 2 do
       
    82         LandTextures[tx, ty].shouldUpdate:= true
       
    83 {$ELSE}
    74 for ty:= Y div TEXSIZE to (Y + Height - 1) div TEXSIZE do
    84 for ty:= Y div TEXSIZE to (Y + Height - 1) div TEXSIZE do
    75     for tx:= X div TEXSIZE to (X + Width - 1) div TEXSIZE do
    85     for tx:= X div TEXSIZE to (X + Width - 1) div TEXSIZE do
    76         LandTextures[tx, ty].shouldUpdate:= true
    86         LandTextures[tx, ty].shouldUpdate:= true
       
    87 {$ENDIF}
    77 end;
    88 end;
    78 
    89 
    79 procedure RealLandTexUpdate;
    90 procedure RealLandTexUpdate;
    80 var x, y: LongWord;
    91 var x, y: LongWord;
    81 begin
    92 begin
   106 RealLandTexUpdate;
   117 RealLandTexUpdate;
   107 
   118 
   108 for x:= 0 to LANDTEXARW -1 do
   119 for x:= 0 to LANDTEXARW -1 do
   109     for y:= 0 to LANDTEXARH - 1 do
   120     for y:= 0 to LANDTEXARH - 1 do
   110         with LandTextures[x, y] do
   121         with LandTextures[x, y] do
       
   122 {$IFDEF DOWNSCALE}
       
   123             DrawTexture(dX + x * TEXSIZE * 2, dY + y * TEXSIZE * 2, tex, 2.0)
       
   124 {$ELSE}
   111             DrawTexture(dX + x * TEXSIZE, dY + y * TEXSIZE, tex)
   125             DrawTexture(dX + x * TEXSIZE, dY + y * TEXSIZE, tex)
       
   126 {$ENDIF}
   112 end;
   127 end;
   113 
   128 
   114 procedure FreeLand;
   129 procedure FreeLand;
   115 var x, y: LongInt;
   130 var x, y: LongInt;
   116 begin
   131 begin