hedgewars/uLandGraphics.pas
changeset 358 236bbd12d4d9
parent 351 29bc9c36ad5f
child 371 731ad6d27bd1
equal deleted inserted replaced
357:165a040e4cfa 358:236bbd12d4d9
   187 
   187 
   188 //
   188 //
   189 //  - (dX, dY) - direction, vector of length = 0.5
   189 //  - (dX, dY) - direction, vector of length = 0.5
   190 //
   190 //
   191 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: integer);
   191 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: integer);
   192 var nx, ny: hwFloat;
   192 var nx, ny, dX8, dY8: hwFloat;
   193     i, t, tx, ty: Longint;
   193     i, t, tx, ty: Longint;
   194 begin  // (-dY, dX) is (dX, dY) rotated by PI/2
   194 begin  // (-dY, dX) is (dX, dY) rotated by PI/2
   195 if SDL_MustLock(LandSurface) then
   195 if SDL_MustLock(LandSurface) then
   196    SDL_LockSurface(LandSurface);
   196    SDL_LockSurface(LandSurface);
   197 
   197 
   198 nx:= X + dY * (HalfWidth + 8);
   198 nx:= X + dY * (HalfWidth + 8);
   199 ny:= Y - dX * (HalfWidth + 8);
   199 ny:= Y - dX * (HalfWidth + 8);
   200 
   200 
       
   201 dX8:= dX * 8;
       
   202 dY8:= dY * 8;
   201 for i:= 0 to 7 do
   203 for i:= 0 to 7 do
   202     begin
   204     begin
   203     X:= nx - 8 * dX;
   205     X:= nx - dX8;
   204     Y:= ny - 8 * dY;
   206     Y:= ny - dY8;
   205     for t:= -8 to ticks + 8 do
   207     for t:= -8 to ticks + 8 do
   206         {$include tunsetborder.inc}
   208         {$include tunsetborder.inc}
   207     nx:= nx - dY;
   209     nx:= nx - dY;
   208     ny:= ny + dX;
   210     ny:= ny + dX;
   209     end;
   211     end;
   210 
   212 
   211 for i:= -HalfWidth to HalfWidth do
   213 for i:= -HalfWidth to HalfWidth do
   212     begin
   214     begin
   213     X:= nx - dX * 8;
   215     X:= nx - dX8;
   214     Y:= ny - dY * 8;
   216     Y:= ny - dY8;
   215     for t:= 0 to 7 do
   217     for t:= 0 to 7 do
   216         {$include tunsetborder.inc}
   218         {$include tunsetborder.inc}
   217     X:= nx;
   219     X:= nx;
   218     Y:= ny;
   220     Y:= ny;
   219     for t:= 0 to ticks do
   221     for t:= 0 to ticks do
   234     ny:= ny + dX;
   236     ny:= ny + dX;
   235     end;
   237     end;
   236 
   238 
   237 for i:= 0 to 7 do
   239 for i:= 0 to 7 do
   238     begin
   240     begin
   239     X:= nx - 8 * dX;
   241     X:= nx - dX8;
   240     Y:= ny - 8 * dY;
   242     Y:= ny - dY8;
   241     for t:= -8 to ticks + 8 do
   243     for t:= -8 to ticks + 8 do
   242         {$include tunsetborder.inc}
   244         {$include tunsetborder.inc}
   243     nx:= nx - dY;
   245     nx:= nx - dY;
   244     ny:= ny + dX;
   246     ny:= ny + dX;
   245     end;
   247     end;