author | koda |
Thu, 05 Nov 2009 20:47:42 +0000 | |
changeset 2602 | 3deb9ff104da |
parent 2599 | c7153d2348f3 |
child 2603 | abed6070a669 |
permissions | -rw-r--r-- |
393 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2005-2008 Andrey Korotaev <unC0Rr@gmail.com> |
393 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*) |
|
18 |
||
184 | 19 |
unit uLandGraphics; |
20 |
interface |
|
409 | 21 |
uses uFloat, uConsts; |
2599 | 22 |
{$INCLUDE "options.inc"} |
184 | 23 |
|
24 |
type PRangeArray = ^TRangeArray; |
|
25 |
TRangeArray = array[0..31] of record |
|
371 | 26 |
Left, Right: LongInt; |
184 | 27 |
end; |
28 |
||
1792 | 29 |
function SweepDirty: boolean; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
30 |
function Despeckle(X, Y: LongInt): boolean; |
2331
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2236
diff
changeset
|
31 |
function CheckLandValue(X, Y: LongInt; Color: Word): boolean; |
371 | 32 |
procedure DrawExplosion(X, Y, Radius: LongInt); |
33 |
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); |
|
34 |
procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
|
35 |
procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword); |
|
511 | 36 |
procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean); |
184 | 37 |
|
520 | 38 |
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean; |
409 | 39 |
|
184 | 40 |
implementation |
1806 | 41 |
uses SDLh, uMisc, uLand, uLandTexture; |
184 | 42 |
|
371 | 43 |
procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword); |
44 |
var i: LongInt; |
|
184 | 45 |
begin |
1753 | 46 |
if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
2376 | 47 |
for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
1753 | 48 |
if Land[y + dy, i] <> COLOR_INDESTRUCTIBLE then |
49 |
Land[y + dy, i]:= Value; |
|
50 |
if ((y - dy) and LAND_HEIGHT_MASK) = 0 then |
|
2376 | 51 |
for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
1753 | 52 |
if Land[y - dy, i] <> COLOR_INDESTRUCTIBLE then |
53 |
Land[y - dy, i]:= Value; |
|
54 |
if ((y + dx) and LAND_HEIGHT_MASK) = 0 then |
|
2376 | 55 |
for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
1753 | 56 |
if Land[y + dx, i] <> COLOR_INDESTRUCTIBLE then |
57 |
Land[y + dx, i]:= Value; |
|
58 |
if ((y - dx) and LAND_HEIGHT_MASK) = 0 then |
|
2376 | 59 |
for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
1753 | 60 |
if Land[y - dx, i] <> COLOR_INDESTRUCTIBLE then |
61 |
Land[y - dx, i]:= Value; |
|
184 | 62 |
end; |
63 |
||
511 | 64 |
procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet: boolean); |
504
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
65 |
var i: LongInt; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
66 |
begin |
511 | 67 |
if not doSet then |
68 |
begin |
|
1753 | 69 |
if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
1760 | 70 |
for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
1861 | 71 |
if (Land[y + dy, i] > 0) and (Land[y + dy, i] < 256) then dec(Land[y + dy, i]); // check > 0 because explosion can erase collision data |
1753 | 72 |
if ((y - dy) and LAND_HEIGHT_MASK) = 0 then |
1760 | 73 |
for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
1861 | 74 |
if (Land[y - dy, i] > 0) and (Land[y - dy, i] < 256) then dec(Land[y - dy, i]); |
1753 | 75 |
if ((y + dx) and LAND_HEIGHT_MASK) = 0 then |
1760 | 76 |
for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
1861 | 77 |
if (Land[y + dx, i] > 0) and (Land[y + dx, i] < 256) then dec(Land[y + dx, i]); |
1753 | 78 |
if ((y - dx) and LAND_HEIGHT_MASK) = 0 then |
1760 | 79 |
for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
1861 | 80 |
if (Land[y - dx, i] > 0) and (Land[y - dx, i] < 256) then dec(Land[y - dx, i]); |
511 | 81 |
end else |
82 |
begin |
|
1753 | 83 |
if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
2376 | 84 |
for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
1861 | 85 |
if (Land[y + dy, i] < 256) then |
86 |
inc(Land[y + dy, i]); |
|
1753 | 87 |
if ((y - dy) and LAND_HEIGHT_MASK) = 0 then |
2376 | 88 |
for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
1861 | 89 |
if (Land[y - dy, i] < 256) then |
90 |
inc(Land[y - dy, i]); |
|
1753 | 91 |
if ((y + dx) and LAND_HEIGHT_MASK) = 0 then |
1861 | 92 |
for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
93 |
if (Land[y + dx, i] < 256) then |
|
94 |
inc(Land[y + dx, i]); |
|
1753 | 95 |
if ((y - dx) and LAND_HEIGHT_MASK) = 0 then |
1861 | 96 |
for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
97 |
if (Land[y - dx, i] < 256) then |
|
98 |
inc(Land[y - dx, i]); |
|
511 | 99 |
end |
504
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
100 |
end; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
101 |
|
371 | 102 |
procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword); |
103 |
var dx, dy, d: LongInt; |
|
184 | 104 |
begin |
105 |
dx:= 0; |
|
106 |
dy:= Radius; |
|
107 |
d:= 3 - 2 * Radius; |
|
108 |
while (dx < dy) do |
|
109 |
begin |
|
110 |
FillCircleLines(x, y, dx, dy, Value); |
|
111 |
if (d < 0) |
|
112 |
then d:= d + 4 * dx + 6 |
|
113 |
else begin |
|
114 |
d:= d + 4 * (dx - dy) + 10; |
|
115 |
dec(dy) |
|
116 |
end; |
|
117 |
inc(dx) |
|
118 |
end; |
|
119 |
if (dx = dy) then FillCircleLines(x, y, dx, dy, Value); |
|
120 |
end; |
|
121 |
||
511 | 122 |
procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean); |
504
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
123 |
var dx, dy, d: LongInt; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
124 |
begin |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
125 |
dx:= 0; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
126 |
dy:= Radius; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
127 |
d:= 3 - 2 * Radius; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
128 |
while (dx < dy) do |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
129 |
begin |
511 | 130 |
ChangeCircleLines(x, y, dx, dy, doSet); |
504
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
131 |
if (d < 0) |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
132 |
then d:= d + 4 * dx + 6 |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
133 |
else begin |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
134 |
d:= d + 4 * (dx - dy) + 10; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
135 |
dec(dy) |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
136 |
end; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
137 |
inc(dx) |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
138 |
end; |
511 | 139 |
if (dx = dy) then ChangeCircleLines(x, y, dx, dy, doSet) |
504
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
140 |
end; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
141 |
|
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
142 |
procedure FillLandCircleLines0(x, y, dx, dy, cr: LongInt); |
371 | 143 |
var i: LongInt; |
184 | 144 |
begin |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
145 |
cr:= cr * cr; // avoid sqrt() to compare lengths/distances |
1753 | 146 |
if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
2376 | 147 |
for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
148 |
if (LandPixels[y + dy, i] and $FF000000) <> 0 then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
149 |
if (dy * dy + (i - x) * (i - x) < cr) or (Land[y + dy, i] = COLOR_OBJECT) then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
150 |
LandPixels[y + dy, i]:= 0 |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
151 |
else |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
152 |
LandPixels[y + dy, i]:= LandBackPixel(i, y + dy); |
1753 | 153 |
if ((y - dy) and LAND_HEIGHT_MASK) = 0 then |
2376 | 154 |
for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
155 |
if (LandPixels[y - dy, i] and $FF000000) <> 0 then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
156 |
if (dy * dy + (i - x) * (i - x) < cr) or (Land[y - dy, i] = COLOR_OBJECT) then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
157 |
LandPixels[y - dy, i]:= 0 |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
158 |
else |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
159 |
LandPixels[y - dy, i]:= LandBackPixel(i, y - dy); |
1753 | 160 |
if ((y + dx) and LAND_HEIGHT_MASK) = 0 then |
2376 | 161 |
for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
162 |
if (LandPixels[y + dx, i] and $FF000000) <> 0 then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
163 |
if (dx * dx + (i - x) * (i - x) < cr) or (Land[y + dx, i] = COLOR_OBJECT) then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
164 |
LandPixels[y + dx, i]:= 0 |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
165 |
else |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
166 |
LandPixels[y + dx, i]:= LandBackPixel(i, y + dx); |
1753 | 167 |
if ((y - dx) and LAND_HEIGHT_MASK) = 0 then |
2376 | 168 |
for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
169 |
if (LandPixels[y - dx, i] and $FF000000) <> 0 then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
170 |
if (dx * dx + (i - x) * (i - x) < cr) or (Land[y - dx, i] = COLOR_OBJECT) then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
171 |
LandPixels[y - dx, i]:= 0 |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
172 |
else |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
173 |
LandPixels[y - dx, i]:= LandBackPixel(i, y - dx); |
184 | 174 |
end; |
175 |
||
371 | 176 |
procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt); |
177 |
var i: LongInt; |
|
184 | 178 |
begin |
1753 | 179 |
if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
1760 | 180 |
for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
181 |
if (Land[y + dy, i] = COLOR_LAND) or (Land[y + dy, i] = COLOR_OBJECT) then |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
182 |
begin |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
183 |
LandPixels[y + dy, i]:= cExplosionBorderColor; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
184 |
// Despeckle(y + dy, i); |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
185 |
LandDirty[(y + dy) div 32, i div 32]:= 1; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
186 |
end; |
1753 | 187 |
if ((y - dy) and LAND_HEIGHT_MASK) = 0 then |
1760 | 188 |
for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
189 |
if (Land[y - dy, i] = COLOR_LAND) or (Land[y - dy, i] = COLOR_OBJECT) then |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
190 |
begin |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
191 |
LandPixels[y - dy, i]:= cExplosionBorderColor; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
192 |
// Despeckle(y - dy, i); |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
193 |
LandDirty[(y - dy) div 32, i div 32]:= 1; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
194 |
end; |
1753 | 195 |
if ((y + dx) and LAND_HEIGHT_MASK) = 0 then |
1760 | 196 |
for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
197 |
if (Land[y + dx, i] = COLOR_LAND) or (Land[y + dx, i] = COLOR_OBJECT) then |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
198 |
begin |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
199 |
LandPixels[y + dx, i]:= cExplosionBorderColor; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
200 |
// Despeckle(y + dx, i); |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
201 |
LandDirty[(y + dx) div 32, i div 32]:= 1; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
202 |
end; |
1753 | 203 |
if ((y - dx) and LAND_HEIGHT_MASK) = 0 then |
1760 | 204 |
for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
205 |
if (Land[y - dx, i] = COLOR_LAND) or (Land[y - dx, i] = COLOR_OBJECT) then |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
206 |
begin |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
207 |
LandPixels[y - dx, i]:= cExplosionBorderColor; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
208 |
// Despeckle(y - dx, i); |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
209 |
LandDirty[(y - dx) div 32, i div 32]:= 1; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
210 |
end; |
184 | 211 |
end; |
212 |
||
371 | 213 |
procedure DrawExplosion(X, Y, Radius: LongInt); |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
214 |
var dx, dy, ty, tx, d, cr: LongInt; |
184 | 215 |
begin |
216 |
dx:= 0; |
|
217 |
dy:= Radius; |
|
218 |
d:= 3 - 2 * Radius; |
|
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
219 |
cr:= Radius * 3 div 4; |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
220 |
if cr < 10 then cr:= 0; |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
221 |
|
184 | 222 |
while (dx < dy) do |
223 |
begin |
|
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
224 |
FillLandCircleLines0(x, y, dx, dy, cr); |
184 | 225 |
if (d < 0) |
226 |
then d:= d + 4 * dx + 6 |
|
227 |
else begin |
|
228 |
d:= d + 4 * (dx - dy) + 10; |
|
229 |
dec(dy) |
|
230 |
end; |
|
231 |
inc(dx) |
|
232 |
end; |
|
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
233 |
if (dx = dy) then FillLandCircleLines0(x, y, dx, dy, cr); |
1849 | 234 |
// FillRoundInLand after erasing land pixels to allow Land 0 check for mask.png to function |
235 |
FillRoundInLand(X, Y, Radius, 0); |
|
184 | 236 |
inc(Radius, 4); |
237 |
dx:= 0; |
|
238 |
dy:= Radius; |
|
239 |
d:= 3 - 2 * Radius; |
|
240 |
while (dx < dy) do |
|
241 |
begin |
|
242 |
FillLandCircleLinesEBC(x, y, dx, dy); |
|
243 |
if (d < 0) |
|
244 |
then d:= d + 4 * dx + 6 |
|
245 |
else begin |
|
246 |
d:= d + 4 * (dx - dy) + 10; |
|
247 |
dec(dy) |
|
248 |
end; |
|
249 |
inc(dx) |
|
250 |
end; |
|
351 | 251 |
if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy); |
252 |
||
1807 | 253 |
tx:= max(X - Radius - 1, 0); |
254 |
dx:= min(X + Radius + 1, LAND_WIDTH) - tx; |
|
255 |
ty:= max(Y - Radius - 1, 0); |
|
256 |
dy:= min(Y + Radius + 1, LAND_HEIGHT) - ty; |
|
257 |
UpdateLandTexture(tx, dx, ty, dy) |
|
184 | 258 |
end; |
259 |
||
371 | 260 |
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); |
184 | 261 |
var tx, ty, i: LongInt; |
262 |
begin |
|
263 |
for i:= 0 to Pred(Count) do |
|
264 |
begin |
|
1753 | 265 |
for ty:= max(y - Radius, 0) to min(y + Radius, LAND_HEIGHT) do |
266 |
for tx:= max(0, ar^[i].Left - Radius) to min(LAND_WIDTH, ar^[i].Right + Radius) do |
|
1849 | 267 |
if Land[ty, tx] = COLOR_LAND then |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
268 |
LandPixels[ty, tx]:= LandBackPixel(tx, ty) |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
269 |
else if Land[ty, tx] = COLOR_OBJECT then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
270 |
LandPixels[ty, tx]:= 0; |
184 | 271 |
inc(y, dY) |
272 |
end; |
|
273 |
||
274 |
inc(Radius, 4); |
|
351 | 275 |
dec(y, Count * dY); |
184 | 276 |
|
277 |
for i:= 0 to Pred(Count) do |
|
278 |
begin |
|
1753 | 279 |
for ty:= max(y - Radius, 0) to min(y + Radius, LAND_HEIGHT) do |
280 |
for tx:= max(0, ar^[i].Left - Radius) to min(LAND_WIDTH, ar^[i].Right + Radius) do |
|
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
281 |
if (Land[ty, tx] = COLOR_LAND) or (Land[ty, tx] = COLOR_OBJECT) then |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
282 |
begin |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
283 |
LandPixels[ty, tx]:= cExplosionBorderColor; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
284 |
LandDirty[trunc((y + dy)/32), trunc(i/32)]:= 1; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
285 |
end; |
184 | 286 |
inc(y, dY) |
287 |
end; |
|
288 |
||
818 | 289 |
|
1807 | 290 |
UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT) |
184 | 291 |
end; |
292 |
||
293 |
// |
|
294 |
// - (dX, dY) - direction, vector of length = 0.5 |
|
295 |
// |
|
371 | 296 |
procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
358 | 297 |
var nx, ny, dX8, dY8: hwFloat; |
1809 | 298 |
i, t, tx, ty, stX, stY, ddy, ddx: Longint; |
184 | 299 |
begin // (-dY, dX) is (dX, dY) rotated by PI/2 |
772
e8d530ca77be
Don't update all land texture when drawing tunnel (saves video throughput)
unc0rr
parents:
769
diff
changeset
|
300 |
stY:= hwRound(Y); |
1809 | 301 |
stX:= hwRound(X); |
772
e8d530ca77be
Don't update all land texture when drawing tunnel (saves video throughput)
unc0rr
parents:
769
diff
changeset
|
302 |
|
184 | 303 |
nx:= X + dY * (HalfWidth + 8); |
304 |
ny:= Y - dX * (HalfWidth + 8); |
|
305 |
||
358 | 306 |
dX8:= dX * 8; |
307 |
dY8:= dY * 8; |
|
184 | 308 |
for i:= 0 to 7 do |
309 |
begin |
|
358 | 310 |
X:= nx - dX8; |
311 |
Y:= ny - dY8; |
|
184 | 312 |
for t:= -8 to ticks + 8 do |
2599 | 313 |
{$INCLUDE "tunsetborder.inc"} |
184 | 314 |
nx:= nx - dY; |
315 |
ny:= ny + dX; |
|
316 |
end; |
|
317 |
||
318 |
for i:= -HalfWidth to HalfWidth do |
|
319 |
begin |
|
358 | 320 |
X:= nx - dX8; |
321 |
Y:= ny - dY8; |
|
184 | 322 |
for t:= 0 to 7 do |
2599 | 323 |
{$INCLUDE "tunsetborder.inc"} |
184 | 324 |
X:= nx; |
325 |
Y:= ny; |
|
326 |
for t:= 0 to ticks do |
|
327 |
begin |
|
328 |
X:= X + dX; |
|
329 |
Y:= Y + dY; |
|
351 | 330 |
tx:= hwRound(X); |
331 |
ty:= hwRound(Y); |
|
1753 | 332 |
if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) then |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
333 |
begin |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
334 |
if Land[ty, tx] = COLOR_LAND then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
335 |
LandPixels[ty, tx]:= LandBackPixel(tx, ty) |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
336 |
else if Land[ty, tx] = COLOR_OBJECT then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
337 |
LandPixels[ty, tx]:= 0; |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
338 |
Land[ty, tx]:= 0; |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
339 |
end |
184 | 340 |
end; |
341 |
for t:= 0 to 7 do |
|
2599 | 342 |
{$INCLUDE "tunsetborder.inc"} |
184 | 343 |
nx:= nx - dY; |
344 |
ny:= ny + dX; |
|
345 |
end; |
|
346 |
||
347 |
for i:= 0 to 7 do |
|
348 |
begin |
|
358 | 349 |
X:= nx - dX8; |
350 |
Y:= ny - dY8; |
|
184 | 351 |
for t:= -8 to ticks + 8 do |
2599 | 352 |
{$INCLUDE "tunsetborder.inc"} |
184 | 353 |
nx:= nx - dY; |
354 |
ny:= ny + dX; |
|
355 |
end; |
|
356 |
||
1809 | 357 |
tx:= max(stX - HalfWidth * 2 - 4 - abs(hwRound(dX * ticks)), 0); |
1807 | 358 |
ty:= max(stY - HalfWidth * 2 - 4 - abs(hwRound(dY * ticks)), 0); |
1809 | 359 |
ddx:= min(stX + HalfWidth * 2 + 4 + abs(hwRound(dX * ticks)), LAND_WIDTH) - tx; |
360 |
ddy:= min(stY + HalfWidth * 2 + 4 + abs(hwRound(dY * ticks)), LAND_HEIGHT) - ty; |
|
361 |
||
362 |
UpdateLandTexture(tx, ddx, ty, ddy) |
|
184 | 363 |
end; |
364 |
||
520 | 365 |
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean; |
2235 | 366 |
var X, Y, bpp, h, w, row, col, numFramesFirstCol: LongInt; |
409 | 367 |
p: PByteArray; |
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
368 |
Image: PSDL_Surface; |
409 | 369 |
begin |
2235 | 370 |
numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height; |
371 |
||
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
372 |
TryDo(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true); |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
373 |
Image:= SpritesData[Obj].Surface; |
409 | 374 |
w:= SpritesData[Obj].Width; |
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
375 |
h:= SpritesData[Obj].Height; |
2235 | 376 |
row:= Frame mod numFramesFirstCol; |
377 |
col:= Frame div numFramesFirstCol; |
|
409 | 378 |
|
379 |
if SDL_MustLock(Image) then |
|
380 |
SDLTry(SDL_LockSurface(Image) >= 0, true); |
|
381 |
||
382 |
bpp:= Image^.format^.BytesPerPixel; |
|
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
383 |
TryDo(bpp = 4, 'It should be 32 bpp sprite', true); |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
384 |
// Check that sprite fits free space |
2236 | 385 |
p:= @(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]); |
409 | 386 |
case bpp of |
387 |
4: for y:= 0 to Pred(h) do |
|
388 |
begin |
|
389 |
for x:= 0 to Pred(w) do |
|
390 |
if PLongword(@(p^[x * 4]))^ <> 0 then |
|
1792 | 391 |
if ((cpY + y) < Longint(topY)) or |
392 |
((cpY + y) > LAND_HEIGHT) or |
|
393 |
((cpX + x) < Longint(leftX)) or |
|
394 |
((cpX + x) > Longint(rightX)) or |
|
409 | 395 |
(Land[cpY + y, cpX + x] <> 0) then |
396 |
begin |
|
397 |
if SDL_MustLock(Image) then |
|
398 |
SDL_UnlockSurface(Image); |
|
399 |
exit(false) |
|
400 |
end; |
|
401 |
p:= @(p^[Image^.pitch]); |
|
402 |
end; |
|
403 |
end; |
|
404 |
||
520 | 405 |
TryPlaceOnLand:= true; |
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
406 |
if not doPlace then |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
407 |
begin |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
408 |
if SDL_MustLock(Image) then |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
409 |
SDL_UnlockSurface(Image); |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
410 |
exit |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
411 |
end; |
520 | 412 |
|
409 | 413 |
// Checked, now place |
2236 | 414 |
p:= @(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]); |
409 | 415 |
case bpp of |
416 |
4: for y:= 0 to Pred(h) do |
|
417 |
begin |
|
418 |
for x:= 0 to Pred(w) do |
|
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
419 |
if PLongword(@(p^[x * 4]))^ <> 0 then |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
420 |
begin |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
421 |
Land[cpY + y, cpX + x]:= COLOR_OBJECT; |
769
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
422 |
LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^ |
788efc1d649f
- Save 8 MB of memory by freeing LandSurface and not using it anymore after game initialization
unc0rr
parents:
768
diff
changeset
|
423 |
end; |
409 | 424 |
p:= @(p^[Image^.pitch]); |
425 |
end; |
|
426 |
end; |
|
427 |
if SDL_MustLock(Image) then |
|
428 |
SDL_UnlockSurface(Image); |
|
429 |
||
1807 | 430 |
x:= max(cpX, leftX); |
431 |
w:= min(cpX + Image^.w, LAND_WIDTH) - x; |
|
1792 | 432 |
y:= max(cpY, topY); |
1753 | 433 |
h:= min(cpY + Image^.h, LAND_HEIGHT) - y; |
1807 | 434 |
UpdateLandTexture(x, w, y, h) |
409 | 435 |
end; |
436 |
||
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
437 |
// was experimenting with applying as damage occurred. |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
438 |
function Despeckle(X, Y: LongInt): boolean; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
439 |
var nx, ny, i, j, c: LongInt; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
440 |
begin |
1792 | 441 |
if (Land[Y, X] <> 0) and (Land[Y, X] <> COLOR_INDESTRUCTIBLE) and (LandPixels[Y, X] = cExplosionBorderColor)then // check neighbours |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
442 |
begin |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
443 |
c:= 0; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
444 |
for i:= -1 to 1 do |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
445 |
for j:= -1 to 1 do |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
446 |
if (i <> 0) or (j <> 0) then |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
447 |
begin |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
448 |
ny:= Y + i; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
449 |
nx:= X + j; |
1753 | 450 |
if ((ny and LAND_HEIGHT_MASK) = 0) and ((nx and LAND_WIDTH_MASK) = 0) then |
1892 | 451 |
if Land[ny, nx] > 255 then |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
452 |
inc(c); |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
453 |
end; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
454 |
|
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
455 |
if c < 4 then // 0-3 neighbours |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
456 |
begin |
2602
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
457 |
if Land[Y, X] = COLOR_LAND then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
458 |
LandPixels[Y, X]:= LandBackPixel(X, Y) |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
459 |
else if Land[Y, X] = COLOR_OBJECT then |
3deb9ff104da
update themes cmakefiles to use GLOB instead of listing all the files
koda
parents:
2599
diff
changeset
|
460 |
LandPixels[Y, X]:= 0; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
461 |
Land[Y, X]:= 0; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
462 |
exit(true); |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
463 |
end; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
464 |
end; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
465 |
Despeckle:= false |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
466 |
end; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
467 |
|
1792 | 468 |
function SweepDirty: boolean; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
469 |
var x, y, xx, yy: LongInt; |
2167
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
470 |
Result, updateBlock, resweep: boolean; |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
471 |
begin |
1792 | 472 |
Result:= false; |
473 |
||
1761 | 474 |
for y:= 0 to LAND_HEIGHT div 32 - 1 do |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
475 |
begin |
2376 | 476 |
|
1761 | 477 |
for x:= 0 to LAND_WIDTH div 32 - 1 do |
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
478 |
begin |
1809 | 479 |
if LandDirty[y, x] <> 0 then |
480 |
begin |
|
481 |
updateBlock:= false; |
|
2167
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
482 |
resweep:= true; |
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
483 |
while(resweep) do |
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
484 |
begin |
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
485 |
resweep:= false; |
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
486 |
for yy:= y * 32 to y * 32 + 31 do |
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
487 |
for xx:= x * 32 to x * 32 + 31 do |
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
488 |
if Despeckle(xx, yy) then |
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
489 |
begin |
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
490 |
Result:= true; |
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
491 |
updateBlock:= true; |
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
492 |
resweep:= true; |
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
493 |
end; |
4e9ad395c1d1
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
nemo
parents:
1892
diff
changeset
|
494 |
end; |
1809 | 495 |
if updateBlock then UpdateLandTexture(x * 32, 32, y * 32, 32); |
496 |
LandDirty[y, x]:= 0; |
|
497 |
end; |
|
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
498 |
end; |
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
499 |
end; |
1792 | 500 |
|
501 |
SweepDirty:= Result |
|
1738
00e8dadce69a
Add nemo's depixeling patch. Still needs some polishing for the case when we delete pixel on which hedgehog stays
unc0rr
parents:
1066
diff
changeset
|
502 |
end; |
184 | 503 |
|
2331
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2236
diff
changeset
|
504 |
// Return true if outside of land or not the value tested, used right now for some X/Y movement that does not use normal hedgehog movement in GSHandlers.inc |
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2236
diff
changeset
|
505 |
function CheckLandValue(X, Y: LongInt; Color: Word): boolean; |
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2236
diff
changeset
|
506 |
begin |
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2236
diff
changeset
|
507 |
CheckLandValue:= ((X and LAND_WIDTH_MASK <> 0) or (Y and LAND_HEIGHT_MASK <> 0)) or (Land[Y, X] <> Color) |
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2236
diff
changeset
|
508 |
end; |
184 | 509 |
end. |