28 end; |
28 end; |
29 |
29 |
30 function SweepDirty: boolean; |
30 function SweepDirty: boolean; |
31 function Despeckle(X, Y: LongInt): boolean; |
31 function Despeckle(X, Y: LongInt): boolean; |
32 function CheckLandValue(X, Y: LongInt; Color: Word): boolean; |
32 function CheckLandValue(X, Y: LongInt; Color: Word): boolean; |
|
33 procedure Despeckle2(X, Y, Threesold: LongInt); |
33 procedure DrawExplosion(X, Y, Radius: LongInt); |
34 procedure DrawExplosion(X, Y, Radius: LongInt); |
34 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); |
35 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); |
35 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
36 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
36 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword); |
37 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword); |
37 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean); |
38 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean); |
38 |
39 |
39 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean; |
40 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean; |
40 |
41 |
41 implementation |
42 implementation |
42 uses SDLh, uMisc, uLand, uLandTexture; |
43 uses SDLh, uMisc, uLand, uLandTexture; |
|
44 |
|
45 procedure Despeckle2(X, Y, Threesold: LongInt); |
|
46 var |
|
47 i, j: LongInt; |
|
48 x0, x1, y0, y1: LongInt; |
|
49 c: byte; |
|
50 begin |
|
51 // If the pixel has less than Threesold neightbours, it gets erased |
|
52 // Erasing is outwards recursive |
|
53 c := 0; |
|
54 |
|
55 x0 := max(X-1, 0); |
|
56 x1 := min(X+1, LAND_WIDTH - 1); |
|
57 y0 := max(Y-1, 0); |
|
58 y1 := min(Y+1, LAND_HEIGHT - 1); |
|
59 |
|
60 for i:=x0 to x1 do begin |
|
61 for j:=y0 to y1 do begin |
|
62 if Land[j, i]<>0 then begin |
|
63 c := c+1; |
|
64 end; |
|
65 end; |
|
66 end; |
|
67 |
|
68 if c<Threesold then begin |
|
69 Land[Y, X] := 0; |
|
70 LandPixels[Y, X] := 0; |
|
71 for i:=x0 to x1 do begin |
|
72 for j:=y0 to y1 do begin |
|
73 if Land[j, i]<>0 then begin |
|
74 LandPixels[j, i] := cExplosionBorderColor; |
|
75 Despeckle2(i, j, 5); |
|
76 end; |
|
77 end; |
|
78 end; |
|
79 end; |
|
80 UpdateLandTexture(x0, x1-x0, y0, y1-y0); |
|
81 end; |
43 |
82 |
44 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword); |
83 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword); |
45 var i: LongInt; |
84 var i: LongInt; |
46 begin |
85 begin |
47 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
86 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
167 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
206 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
168 for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
207 for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
169 if Land[y + dy, i] = COLOR_LAND then |
208 if Land[y + dy, i] = COLOR_LAND then |
170 begin |
209 begin |
171 LandPixels[y + dy, i]:= cExplosionBorderColor; |
210 LandPixels[y + dy, i]:= cExplosionBorderColor; |
172 // Despeckle(y + dy, i); |
211 Despeckle2(i, y + dy, 6); |
173 LandDirty[(y + dy) div 32, i div 32]:= 1; |
212 LandDirty[(y + dy) div 32, i div 32]:= 1; |
174 end; |
213 end; |
175 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then |
214 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then |
176 for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
215 for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do |
177 if Land[y - dy, i] = COLOR_LAND then |
216 if Land[y - dy, i] = COLOR_LAND then |
178 begin |
217 begin |
179 LandPixels[y - dy, i]:= cExplosionBorderColor; |
218 LandPixels[y - dy, i]:= cExplosionBorderColor; |
180 // Despeckle(y - dy, i); |
219 Despeckle2(i, y - dy, 6); |
181 LandDirty[(y - dy) div 32, i div 32]:= 1; |
220 LandDirty[(y - dy) div 32, i div 32]:= 1; |
182 end; |
221 end; |
183 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then |
222 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then |
184 for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
223 for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
185 if Land[y + dx, i] = COLOR_LAND then |
224 if Land[y + dx, i] = COLOR_LAND then |
186 begin |
225 begin |
187 LandPixels[y + dx, i]:= cExplosionBorderColor; |
226 LandPixels[y + dx, i]:= cExplosionBorderColor; |
188 // Despeckle(y + dx, i); |
227 Despeckle2(i, y + dx, 6); |
189 LandDirty[(y + dx) div 32, i div 32]:= 1; |
228 LandDirty[(y + dx) div 32, i div 32]:= 1; |
190 end; |
229 end; |
191 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then |
230 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then |
192 for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
231 for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do |
193 if Land[y - dx, i] = COLOR_LAND then |
232 if Land[y - dx, i] = COLOR_LAND then |
194 begin |
233 begin |
195 LandPixels[y - dx, i]:= cExplosionBorderColor; |
234 LandPixels[y - dx, i]:= cExplosionBorderColor; |
196 // Despeckle(y - dx, i); |
235 Despeckle2(i, y - dy, 6); |
197 LandDirty[(y - dx) div 32, i div 32]:= 1; |
236 LandDirty[(y - dx) div 32, i div 32]:= 1; |
198 end; |
237 end; |
199 end; |
238 end; |
200 |
239 |
201 procedure DrawExplosion(X, Y, Radius: LongInt); |
240 procedure DrawExplosion(X, Y, Radius: LongInt); |