hedgewars/uLandGraphics.pas
changeset 1807 795f97007833
parent 1806 3c4f0886c123
child 1809 77923087a1ce
equal deleted inserted replaced
1806:3c4f0886c123 1807:795f97007833
   187           LandDirty[(y - dx) div 32, i div 32]:= 1;
   187           LandDirty[(y - dx) div 32, i div 32]:= 1;
   188           end;
   188           end;
   189 end;
   189 end;
   190 
   190 
   191 procedure DrawExplosion(X, Y, Radius: LongInt);
   191 procedure DrawExplosion(X, Y, Radius: LongInt);
   192 var dx, dy, d: LongInt;
   192 var dx, dy, ty, tx, d: LongInt;
   193 begin
   193 begin
   194 FillRoundInLand(X, Y, Radius, 0);
   194 FillRoundInLand(X, Y, Radius, 0);
   195 
   195 
   196   dx:= 0;
   196   dx:= 0;
   197   dy:= Radius;
   197   dy:= Radius;
   223           end;
   223           end;
   224      inc(dx)
   224      inc(dx)
   225      end;
   225      end;
   226   if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy);
   226   if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy);
   227 
   227 
   228 d:= max(Y - Radius - 1, 0);
   228 tx:= max(X - Radius - 1, 0);
   229 dy:= min(Y + Radius + 1, LAND_HEIGHT) - d;
   229 dx:= min(X + Radius + 1, LAND_WIDTH) - tx;
   230 UpdateLandTexture(d, dy)
   230 ty:= max(Y - Radius - 1, 0);
       
   231 dy:= min(Y + Radius + 1, LAND_HEIGHT) - ty;
       
   232 UpdateLandTexture(tx, dx, ty, dy)
   231 end;
   233 end;
   232 
   234 
   233 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
   235 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
   234 var tx, ty, i: LongInt;
   236 var tx, ty, i: LongInt;
   235 begin
   237 begin
   256                 end;
   258                 end;
   257     inc(y, dY)
   259     inc(y, dY)
   258     end;
   260     end;
   259 
   261 
   260 
   262 
   261 UpdateLandTexture(0, LAND_HEIGHT)
   263 UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT)
   262 end;
   264 end;
   263 
   265 
   264 //
   266 //
   265 //  - (dX, dY) - direction, vector of length = 0.5
   267 //  - (dX, dY) - direction, vector of length = 0.5
   266 //
   268 //
   267 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
   269 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
   268 var nx, ny, dX8, dY8: hwFloat;
   270 var nx, ny, dX8, dY8: hwFloat;
   269     i, t, tx, ty, stY: Longint;
   271     i, t, tx, ty, stY, ddy: Longint;
   270 begin  // (-dY, dX) is (dX, dY) rotated by PI/2
   272 begin  // (-dY, dX) is (dX, dY) rotated by PI/2
   271 stY:= hwRound(Y);
   273 stY:= hwRound(Y);
   272 
   274 
   273 nx:= X + dY * (HalfWidth + 8);
   275 nx:= X + dY * (HalfWidth + 8);
   274 ny:= Y - dX * (HalfWidth + 8);
   276 ny:= Y - dX * (HalfWidth + 8);
   320         {$include tunsetborder.inc}
   322         {$include tunsetborder.inc}
   321     nx:= nx - dY;
   323     nx:= nx - dY;
   322     ny:= ny + dX;
   324     ny:= ny + dX;
   323     end;
   325     end;
   324 
   326 
   325 t:= max(stY - HalfWidth * 2 - 4 - abs(hwRound(dY * ticks)), 0);
   327 ty:= max(stY - HalfWidth * 2 - 4 - abs(hwRound(dY * ticks)), 0);
   326 ty:= min(stY + HalfWidth * 2 + 4 + abs(hwRound(dY * ticks)), LAND_HEIGHT) - t;
   328 ddy:= min(stY + HalfWidth * 2 + 4 + abs(hwRound(dY * ticks)), LAND_HEIGHT) - t;
   327 UpdateLandTexture(t, ty)
   329 UpdateLandTexture(0, LAND_WIDTH, ty, ddy)
   328 end;
   330 end;
   329 
   331 
   330 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
   332 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
   331 var X, Y, bpp, h, w: LongInt;
   333 var X, Y, bpp, h, w: LongInt;
   332     p: PByteArray;
   334     p: PByteArray;
   386             end;
   388             end;
   387      end;
   389      end;
   388 if SDL_MustLock(Image) then
   390 if SDL_MustLock(Image) then
   389    SDL_UnlockSurface(Image);
   391    SDL_UnlockSurface(Image);
   390 
   392 
       
   393 x:= max(cpX, leftX);
       
   394 w:= min(cpX + Image^.w, LAND_WIDTH) - x;
   391 y:= max(cpY, topY);
   395 y:= max(cpY, topY);
   392 h:= min(cpY + Image^.h, LAND_HEIGHT) - y;
   396 h:= min(cpY + Image^.h, LAND_HEIGHT) - y;
   393 UpdateLandTexture(y, h)
   397 UpdateLandTexture(x, w, y, h)
   394 end;
   398 end;
   395 
   399 
   396 // was experimenting with applying as damage occurred.
   400 // was experimenting with applying as damage occurred.
   397 function Despeckle(X, Y: LongInt): boolean;
   401 function Despeckle(X, Y: LongInt): boolean;
   398 var nx, ny, i, j, c: LongInt;
   402 var nx, ny, i, j, c: LongInt;
   448 		LandDirty[y, x]:= 0;
   452 		LandDirty[y, x]:= 0;
   449 		end;
   453 		end;
   450 	
   454 	
   451 	if updatedRow then
   455 	if updatedRow then
   452 		begin
   456 		begin
   453 		UpdateLandTexture(y * 32, 32);
   457 		UpdateLandTexture(x * 32, 32, y * 32, 32);
   454 		Result:= true
   458 		Result:= true
   455 		end
   459 		end
   456 	end;
   460 	end;
   457 
   461 
   458 SweepDirty:= Result
   462 SweepDirty:= Result