--- a/hedgewars/uLandGraphics.pas Mon May 28 10:38:27 2012 +0200
+++ b/hedgewars/uLandGraphics.pas Tue Jun 05 22:17:06 2012 +0200
@@ -39,6 +39,7 @@
procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
function LandBackPixel(x, y: LongInt): LongWord;
procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword);
+procedure DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword);
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean;
@@ -462,7 +463,7 @@
dx:= Min(X + Radius + 1, LAND_WIDTH) - tx;
ty:= Max(Y - Radius - 1, 0);
dy:= Min(Y + Radius + 1, LAND_HEIGHT) - ty;
-UpdateLandTexture(tx, dx, ty, dy);
+UpdateLandTexture(tx, dx, ty, dy, false);
DrawExplosion:= cnt
end;
@@ -514,7 +515,7 @@
end;
-UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT)
+UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT, false)
end;
//
@@ -664,7 +665,7 @@
ddx:= Min(stX + HalfWidth * 2 + 4 + abs(hwRound(dX * ticks)), LAND_WIDTH) - tx;
ddy:= Min(stY + HalfWidth * 2 + 4 + abs(hwRound(dY * ticks)), LAND_HEIGHT) - ty;
-UpdateLandTexture(tx, ddx, ty, ddy)
+UpdateLandTexture(tx, ddx, ty, ddy, false)
end;
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean;
@@ -752,7 +753,7 @@
w:= Min(cpX + Image^.w, LAND_WIDTH) - x;
y:= Max(cpY, topY);
h:= Min(cpY + Image^.h, LAND_HEIGHT) - y;
-UpdateLandTexture(x, w, y, h)
+UpdateLandTexture(x, w, y, h, true)
end;
function Despeckle(X, Y: LongInt): boolean;
@@ -954,7 +955,7 @@
end;
end;
if updateBlock then
- UpdateLandTexture(tx, 32, ty, 32);
+ UpdateLandTexture(tx, 32, ty, 32, false);
LandDirty[y, x]:= 2;
end;
end;
@@ -1056,4 +1057,104 @@
end
end;
+procedure DrawDots(x, y, xx, yy: Longint; Color: Longword); inline;
+begin
+ if (((x + xx) and LAND_WIDTH_MASK) = 0) and (((y + yy) and LAND_HEIGHT_MASK) = 0) then Land[y + yy, x + xx]:= Color;
+ if (((x + xx) and LAND_WIDTH_MASK) = 0) and (((y - yy) and LAND_HEIGHT_MASK) = 0) then Land[y - yy, x + xx]:= Color;
+ if (((x - xx) and LAND_WIDTH_MASK) = 0) and (((y + yy) and LAND_HEIGHT_MASK) = 0) then Land[y + yy, x - xx]:= Color;
+ if (((x - xx) and LAND_WIDTH_MASK) = 0) and (((y - yy) and LAND_HEIGHT_MASK) = 0) then Land[y - yy, x - xx]:= Color;
+ if (((x + yy) and LAND_WIDTH_MASK) = 0) and (((y + xx) and LAND_HEIGHT_MASK) = 0) then Land[y + xx, x + yy]:= Color;
+ if (((x + yy) and LAND_WIDTH_MASK) = 0) and (((y - xx) and LAND_HEIGHT_MASK) = 0) then Land[y - xx, x + yy]:= Color;
+ if (((x - yy) and LAND_WIDTH_MASK) = 0) and (((y + xx) and LAND_HEIGHT_MASK) = 0) then Land[y + xx, x - yy]:= Color;
+ if (((x - yy) and LAND_WIDTH_MASK) = 0) and (((y - xx) and LAND_HEIGHT_MASK) = 0) then Land[y - xx, x - yy]:= Color;
+end;
+
+procedure DrawLines(X1, Y1, X2, Y2, XX, YY: LongInt; color: Longword);
+var
+ eX, eY, dX, dY: LongInt;
+ i, sX, sY, x, y, d: LongInt;
+ f: boolean;
+begin
+ eX:= 0;
+ eY:= 0;
+ dX:= X2 - X1;
+ dY:= Y2 - Y1;
+
+ if (dX > 0) then
+ sX:= 1
+ else
+ if (dX < 0) then
+ begin
+ sX:= -1;
+ dX:= -dX
+ end
+ else
+ sX:= dX;
+
+ if (dY > 0) then
+ sY:= 1
+ else
+ if (dY < 0) then
+ begin
+ sY:= -1;
+ dY:= -dY
+ end
+ else
+ sY:= dY;
+
+ if (dX > dY) then
+ d:= dX
+ else
+ d:= dY;
+
+ x:= X1;
+ y:= Y1;
+
+ for i:= 0 to d do
+ begin
+ inc(eX, dX);
+ inc(eY, dY);
+
+ f:= eX > d;
+ if f then
+ begin
+ dec(eX, d);
+ inc(x, sX);
+ DrawDots(x, y, xx, yy, color)
+ end;
+ if (eY > d) then
+ begin
+ dec(eY, d);
+ inc(y, sY);
+ f:= true;
+ DrawDots(x, y, xx, yy, color)
+ end;
+
+ if not f then
+ DrawDots(x, y, xx, yy, color)
+ end
+end;
+
+procedure DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword);
+var dx, dy, d: LongInt;
+begin
+ dx:= 0;
+ dy:= Radius;
+ d:= 3 - 2 * Radius;
+ while (dx < dy) do
+ begin
+ DrawLines(x1, y1, x2, y2, dx, dy, color);
+ if (d < 0) then
+ d:= d + 4 * dx + 6
+ else
+ begin
+ d:= d + 4 * (dx - dy) + 10;
+ dec(dy)
+ end;
+ inc(dx)
+ end;
+ if (dx = dy) then
+ DrawLines(x1, y1, x2, y2, dx, dy, color);
+end;
+
end.