author | unc0rr |
Sun, 08 Jul 2007 17:16:46 +0000 | |
changeset 553 | 5478386d935f |
parent 520 | e83dfb7ffead |
child 698 | 43f3ef079f53 |
permissions | -rw-r--r-- |
393 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
3 |
* Copyright (c) 2005-2007 Andrey Korotaev <unC0Rr@gmail.com> |
|
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; |
345 | 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 |
||
371 | 29 |
procedure DrawExplosion(X, Y, Radius: LongInt); |
30 |
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); |
|
31 |
procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
|
32 |
procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword); |
|
511 | 33 |
procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean); |
184 | 34 |
|
520 | 35 |
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean; |
409 | 36 |
|
184 | 37 |
implementation |
409 | 38 |
uses SDLh, uMisc, uLand; |
184 | 39 |
|
371 | 40 |
procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword); |
41 |
var i: LongInt; |
|
184 | 42 |
begin |
43 |
if ((y + dy) and $FFFFFC00) = 0 then |
|
44 |
for i:= max(x - dx, 0) to min(x + dx, 2047) do Land[y + dy, i]:= Value; |
|
45 |
if ((y - dy) and $FFFFFC00) = 0 then |
|
46 |
for i:= max(x - dx, 0) to min(x + dx, 2047) do Land[y - dy, i]:= Value; |
|
47 |
if ((y + dx) and $FFFFFC00) = 0 then |
|
48 |
for i:= max(x - dy, 0) to min(x + dy, 2047) do Land[y + dx, i]:= Value; |
|
49 |
if ((y - dx) and $FFFFFC00) = 0 then |
|
50 |
for i:= max(x - dy, 0) to min(x + dy, 2047) do Land[y - dx, i]:= Value; |
|
51 |
end; |
|
52 |
||
511 | 53 |
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
|
54 |
var i: LongInt; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
55 |
begin |
511 | 56 |
if not doSet then |
57 |
begin |
|
58 |
if ((y + dy) and $FFFFFC00) = 0 then |
|
59 |
for i:= max(x - dx, 0) to min(x + dx, 2047) do |
|
60 |
if (Land[y + dy, i] > 0) then dec(Land[y + dy, i]); |
|
61 |
if ((y - dy) and $FFFFFC00) = 0 then |
|
62 |
for i:= max(x - dx, 0) to min(x + dx, 2047) do |
|
63 |
if (Land[y - dy, i] > 0) then dec(Land[y - dy, i]); |
|
64 |
if ((y + dx) and $FFFFFC00) = 0 then |
|
65 |
for i:= max(x - dy, 0) to min(x + dy, 2047) do |
|
66 |
if (Land[y + dx, i] > 0) then dec(Land[y + dx, i]); |
|
67 |
if ((y - dx) and $FFFFFC00) = 0 then |
|
68 |
for i:= max(x - dy, 0) to min(x + dy, 2047) do |
|
69 |
if (Land[y - dx, i] > 0) then dec(Land[y - dx, i]); |
|
70 |
end else |
|
71 |
begin |
|
72 |
if ((y + dy) and $FFFFFC00) = 0 then |
|
73 |
for i:= max(x - dx, 0) to min(x + dx, 2047) do inc(Land[y + dy, i]); |
|
74 |
if ((y - dy) and $FFFFFC00) = 0 then |
|
75 |
for i:= max(x - dx, 0) to min(x + dx, 2047) do inc(Land[y - dy, i]); |
|
76 |
if ((y + dx) and $FFFFFC00) = 0 then |
|
77 |
for i:= max(x - dy, 0) to min(x + dy, 2047) do inc(Land[y + dx, i]); |
|
78 |
if ((y - dx) and $FFFFFC00) = 0 then |
|
79 |
for i:= max(x - dy, 0) to min(x + dy, 2047) do inc(Land[y - dx, i]); |
|
80 |
end |
|
504
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
81 |
end; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
82 |
|
371 | 83 |
procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword); |
84 |
var dx, dy, d: LongInt; |
|
184 | 85 |
begin |
86 |
dx:= 0; |
|
87 |
dy:= Radius; |
|
88 |
d:= 3 - 2 * Radius; |
|
89 |
while (dx < dy) do |
|
90 |
begin |
|
91 |
FillCircleLines(x, y, dx, dy, Value); |
|
92 |
if (d < 0) |
|
93 |
then d:= d + 4 * dx + 6 |
|
94 |
else begin |
|
95 |
d:= d + 4 * (dx - dy) + 10; |
|
96 |
dec(dy) |
|
97 |
end; |
|
98 |
inc(dx) |
|
99 |
end; |
|
100 |
if (dx = dy) then FillCircleLines(x, y, dx, dy, Value); |
|
101 |
end; |
|
102 |
||
511 | 103 |
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
|
104 |
var dx, dy, d: LongInt; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
105 |
begin |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
106 |
dx:= 0; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
107 |
dy:= Radius; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
108 |
d:= 3 - 2 * Radius; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
109 |
while (dx < dy) do |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
110 |
begin |
511 | 111 |
ChangeCircleLines(x, y, dx, dy, doSet); |
504
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
112 |
if (d < 0) |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
113 |
then d:= d + 4 * dx + 6 |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
114 |
else begin |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
115 |
d:= d + 4 * (dx - dy) + 10; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
116 |
dec(dy) |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
117 |
end; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
118 |
inc(dx) |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
119 |
end; |
511 | 120 |
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
|
121 |
end; |
13b6ebc53627
Fix collision info artifacts in Land array when two objects intersect
unc0rr
parents:
495
diff
changeset
|
122 |
|
371 | 123 |
procedure ClearLandPixel(y, x: LongInt); |
184 | 124 |
var p: PByteArray; |
125 |
begin |
|
351 | 126 |
p:= @PByteArray(LandSurface^.pixels)^[LandSurface^.pitch * y]; |
127 |
case LandSurface^.format^.BytesPerPixel of |
|
128 |
2: PWord(@(p^[x * 2]))^:= 0; |
|
184 | 129 |
3: begin |
351 | 130 |
p^[x * 3 + 0]:= 0; |
131 |
p^[x * 3 + 1]:= 0; |
|
132 |
p^[x * 3 + 2]:= 0; |
|
184 | 133 |
end; |
351 | 134 |
4: PLongword(@(p^[x * 4]))^:= 0; |
184 | 135 |
end |
136 |
end; |
|
137 |
||
371 | 138 |
procedure SetLandPixel(y, x: LongInt); |
184 | 139 |
var p: PByteArray; |
140 |
begin |
|
351 | 141 |
p:= @PByteArray(LandSurface^.pixels)^[LandSurface^.pitch * y]; |
142 |
case LandSurface^.format^.BytesPerPixel of |
|
143 |
2: PWord(@(p^[x * 2]))^:= cExplosionBorderColor; |
|
184 | 144 |
3: begin |
351 | 145 |
p^[x * 3 + 0]:= cExplosionBorderColor and $FF; |
146 |
p^[x * 3 + 1]:= (cExplosionBorderColor shr 8) and $FF; |
|
147 |
p^[x * 3 + 2]:= cExplosionBorderColor shr 16; |
|
184 | 148 |
end; |
351 | 149 |
4: PLongword(@(p^[x * 4]))^:= cExplosionBorderColor; |
184 | 150 |
end |
151 |
end; |
|
152 |
||
371 | 153 |
procedure FillLandCircleLines0(x, y, dx, dy: LongInt); |
154 |
var i: LongInt; |
|
184 | 155 |
begin |
156 |
if ((y + dy) and $FFFFFC00) = 0 then |
|
157 |
for i:= max(x - dx, 0) to min(x + dx, 2047) do ClearLandPixel(y + dy, i); |
|
158 |
if ((y - dy) and $FFFFFC00) = 0 then |
|
159 |
for i:= max(x - dx, 0) to min(x + dx, 2047) do ClearLandPixel(y - dy, i); |
|
160 |
if ((y + dx) and $FFFFFC00) = 0 then |
|
161 |
for i:= max(x - dy, 0) to min(x + dy, 2047) do ClearLandPixel(y + dx, i); |
|
162 |
if ((y - dx) and $FFFFFC00) = 0 then |
|
163 |
for i:= max(x - dy, 0) to min(x + dy, 2047) do ClearLandPixel(y - dx, i); |
|
164 |
end; |
|
165 |
||
371 | 166 |
procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt); |
167 |
var i: LongInt; |
|
184 | 168 |
begin |
169 |
if ((y + dy) and $FFFFFC00) = 0 then |
|
170 |
for i:= max(x - dx, 0) to min(x + dx, 2047) do |
|
171 |
if Land[y + dy, i] = COLOR_LAND then SetLandPixel(y + dy, i); |
|
172 |
if ((y - dy) and $FFFFFC00) = 0 then |
|
173 |
for i:= max(x - dx, 0) to min(x + dx, 2047) do |
|
174 |
if Land[y - dy, i] = COLOR_LAND then SetLandPixel(y - dy, i); |
|
175 |
if ((y + dx) and $FFFFFC00) = 0 then |
|
176 |
for i:= max(x - dy, 0) to min(x + dy, 2047) do |
|
177 |
if Land[y + dx, i] = COLOR_LAND then SetLandPixel(y + dx, i); |
|
178 |
if ((y - dx) and $FFFFFC00) = 0 then |
|
179 |
for i:= max(x - dy, 0) to min(x + dy, 2047) do |
|
180 |
if Land[y - dx, i] = COLOR_LAND then SetLandPixel(y - dx, i); |
|
181 |
end; |
|
182 |
||
371 | 183 |
procedure DrawExplosion(X, Y, Radius: LongInt); |
184 |
var dx, dy, d: LongInt; |
|
184 | 185 |
begin |
186 |
FillRoundInLand(X, Y, Radius, 0); |
|
187 |
||
188 |
if SDL_MustLock(LandSurface) then |
|
189 |
SDLTry(SDL_LockSurface(LandSurface) >= 0, true); |
|
190 |
||
191 |
dx:= 0; |
|
192 |
dy:= Radius; |
|
193 |
d:= 3 - 2 * Radius; |
|
194 |
while (dx < dy) do |
|
195 |
begin |
|
196 |
FillLandCircleLines0(x, y, dx, dy); |
|
197 |
if (d < 0) |
|
198 |
then d:= d + 4 * dx + 6 |
|
199 |
else begin |
|
200 |
d:= d + 4 * (dx - dy) + 10; |
|
201 |
dec(dy) |
|
202 |
end; |
|
203 |
inc(dx) |
|
204 |
end; |
|
205 |
if (dx = dy) then FillLandCircleLines0(x, y, dx, dy); |
|
206 |
inc(Radius, 4); |
|
207 |
dx:= 0; |
|
208 |
dy:= Radius; |
|
209 |
d:= 3 - 2 * Radius; |
|
210 |
while (dx < dy) do |
|
211 |
begin |
|
212 |
FillLandCircleLinesEBC(x, y, dx, dy); |
|
213 |
if (d < 0) |
|
214 |
then d:= d + 4 * dx + 6 |
|
215 |
else begin |
|
216 |
d:= d + 4 * (dx - dy) + 10; |
|
217 |
dec(dy) |
|
218 |
end; |
|
219 |
inc(dx) |
|
220 |
end; |
|
351 | 221 |
if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy); |
222 |
||
184 | 223 |
if SDL_MustLock(LandSurface) then |
224 |
SDL_UnlockSurface(LandSurface); |
|
225 |
end; |
|
226 |
||
371 | 227 |
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); |
184 | 228 |
var tx, ty, i: LongInt; |
229 |
begin |
|
230 |
if SDL_MustLock(LandSurface) then |
|
231 |
SDL_LockSurface(LandSurface); |
|
232 |
||
233 |
for i:= 0 to Pred(Count) do |
|
234 |
begin |
|
188 | 235 |
for ty:= max(y - Radius, 0) to min(y + Radius, 1023) do |
351 | 236 |
for tx:= max(0, ar^[i].Left - Radius) to min(2047, ar^[i].Right + Radius) do |
188 | 237 |
ClearLandPixel(ty, tx); |
184 | 238 |
inc(y, dY) |
239 |
end; |
|
240 |
||
241 |
inc(Radius, 4); |
|
351 | 242 |
dec(y, Count * dY); |
184 | 243 |
|
244 |
for i:= 0 to Pred(Count) do |
|
245 |
begin |
|
188 | 246 |
for ty:= max(y - Radius, 0) to min(y + Radius, 1023) do |
351 | 247 |
for tx:= max(0, ar^[i].Left - Radius) to min(2047, ar^[i].Right + Radius) do |
188 | 248 |
if Land[ty, tx] = $FFFFFF then |
249 |
SetLandPixel(ty, tx); |
|
184 | 250 |
inc(y, dY) |
251 |
end; |
|
252 |
||
253 |
if SDL_MustLock(LandSurface) then |
|
254 |
SDL_UnlockSurface(LandSurface); |
|
255 |
end; |
|
256 |
||
257 |
// |
|
258 |
// - (dX, dY) - direction, vector of length = 0.5 |
|
259 |
// |
|
371 | 260 |
procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
358 | 261 |
var nx, ny, dX8, dY8: hwFloat; |
184 | 262 |
i, t, tx, ty: Longint; |
263 |
begin // (-dY, dX) is (dX, dY) rotated by PI/2 |
|
264 |
if SDL_MustLock(LandSurface) then |
|
265 |
SDL_LockSurface(LandSurface); |
|
266 |
||
267 |
nx:= X + dY * (HalfWidth + 8); |
|
268 |
ny:= Y - dX * (HalfWidth + 8); |
|
269 |
||
358 | 270 |
dX8:= dX * 8; |
271 |
dY8:= dY * 8; |
|
184 | 272 |
for i:= 0 to 7 do |
273 |
begin |
|
358 | 274 |
X:= nx - dX8; |
275 |
Y:= ny - dY8; |
|
184 | 276 |
for t:= -8 to ticks + 8 do |
277 |
{$include tunsetborder.inc} |
|
278 |
nx:= nx - dY; |
|
279 |
ny:= ny + dX; |
|
280 |
end; |
|
281 |
||
282 |
for i:= -HalfWidth to HalfWidth do |
|
283 |
begin |
|
358 | 284 |
X:= nx - dX8; |
285 |
Y:= ny - dY8; |
|
184 | 286 |
for t:= 0 to 7 do |
287 |
{$include tunsetborder.inc} |
|
288 |
X:= nx; |
|
289 |
Y:= ny; |
|
290 |
for t:= 0 to ticks do |
|
291 |
begin |
|
292 |
X:= X + dX; |
|
293 |
Y:= Y + dY; |
|
351 | 294 |
tx:= hwRound(X); |
295 |
ty:= hwRound(Y); |
|
184 | 296 |
if ((ty and $FFFFFC00) = 0) and ((tx and $FFFFF800) = 0) then |
511 | 297 |
if Land[ty, tx] = COLOR_LAND then |
184 | 298 |
begin |
299 |
Land[ty, tx]:= 0; |
|
300 |
ClearLandPixel(ty, tx); |
|
301 |
end |
|
302 |
end; |
|
303 |
for t:= 0 to 7 do |
|
304 |
{$include tunsetborder.inc} |
|
305 |
nx:= nx - dY; |
|
306 |
ny:= ny + dX; |
|
307 |
end; |
|
308 |
||
309 |
for i:= 0 to 7 do |
|
310 |
begin |
|
358 | 311 |
X:= nx - dX8; |
312 |
Y:= ny - dY8; |
|
184 | 313 |
for t:= -8 to ticks + 8 do |
314 |
{$include tunsetborder.inc} |
|
315 |
nx:= nx - dY; |
|
316 |
ny:= ny + dX; |
|
317 |
end; |
|
318 |
||
319 |
if SDL_MustLock(LandSurface) then |
|
320 |
SDL_UnlockSurface(LandSurface) |
|
321 |
end; |
|
322 |
||
520 | 323 |
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean; |
495 | 324 |
var X, Y, bpp, h, w: LongInt; |
409 | 325 |
p: PByteArray; |
326 |
r, rr: TSDL_Rect; |
|
327 |
Image: PSDL_Surface; |
|
328 |
begin |
|
329 |
Image:= SpritesData[Obj].Surface; |
|
330 |
w:= SpritesData[Obj].Width; |
|
331 |
h:= SpritesData[Obj].Height; |
|
332 |
||
333 |
if SDL_MustLock(Image) then |
|
334 |
SDLTry(SDL_LockSurface(Image) >= 0, true); |
|
335 |
||
336 |
bpp:= Image^.format^.BytesPerPixel; |
|
337 |
TryDo(bpp <> 1, 'We don''t work with 8 bit surfaces', true); |
|
338 |
// Check that sprites fits free space |
|
339 |
p:= @(PByteArray(Image^.pixels)^[Image^.pitch * Frame * h]); |
|
340 |
case bpp of |
|
341 |
2: for y:= 0 to Pred(h) do |
|
342 |
begin |
|
343 |
for x:= 0 to Pred(w) do |
|
344 |
if PWord(@(p^[x * 2]))^ <> 0 then |
|
345 |
if (((cpY + y) and $FFFFFC00) <> 0) or |
|
346 |
(((cpX + x) and $FFFFF800) <> 0) or |
|
347 |
(Land[cpY + y, cpX + x] <> 0) then |
|
348 |
begin |
|
349 |
if SDL_MustLock(Image) then |
|
350 |
SDL_UnlockSurface(Image); |
|
351 |
exit(false) |
|
352 |
end; |
|
353 |
p:= @(p^[Image^.pitch]); |
|
354 |
end; |
|
355 |
3: for y:= 0 to Pred(h) do |
|
356 |
begin |
|
357 |
for x:= 0 to Pred(w) do |
|
358 |
if (p^[x * 3 + 0] <> 0) |
|
359 |
or (p^[x * 3 + 1] <> 0) |
|
360 |
or (p^[x * 3 + 2] <> 0) then |
|
361 |
if (((cpY + y) and $FFFFFC00) <> 0) or |
|
362 |
(((cpX + x) and $FFFFF800) <> 0) or |
|
363 |
(Land[cpY + y, cpX + x] <> 0) then |
|
364 |
begin |
|
365 |
if SDL_MustLock(Image) then |
|
366 |
SDL_UnlockSurface(Image); |
|
367 |
exit(false) |
|
368 |
end; |
|
369 |
p:= @(p^[Image^.pitch]); |
|
370 |
end; |
|
371 |
4: for y:= 0 to Pred(h) do |
|
372 |
begin |
|
373 |
for x:= 0 to Pred(w) do |
|
374 |
if PLongword(@(p^[x * 4]))^ <> 0 then |
|
375 |
if (((cpY + y) and $FFFFFC00) <> 0) or |
|
376 |
(((cpX + x) and $FFFFF800) <> 0) or |
|
377 |
(Land[cpY + y, cpX + x] <> 0) then |
|
378 |
begin |
|
379 |
if SDL_MustLock(Image) then |
|
380 |
SDL_UnlockSurface(Image); |
|
381 |
exit(false) |
|
382 |
end; |
|
383 |
p:= @(p^[Image^.pitch]); |
|
384 |
end; |
|
385 |
end; |
|
386 |
||
520 | 387 |
TryPlaceOnLand:= true; |
388 |
if not doPlace then exit; |
|
389 |
||
409 | 390 |
// Checked, now place |
391 |
p:= @(PByteArray(Image^.pixels)^[Image^.pitch * Frame * h]); |
|
392 |
case bpp of |
|
393 |
2: for y:= 0 to Pred(h) do |
|
394 |
begin |
|
395 |
for x:= 0 to Pred(w) do |
|
396 |
if PWord(@(p^[x * 2]))^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND; |
|
397 |
p:= @(p^[Image^.pitch]); |
|
398 |
end; |
|
399 |
3: for y:= 0 to Pred(h) do |
|
400 |
begin |
|
401 |
for x:= 0 to Pred(w) do |
|
402 |
if (p^[x * 3 + 0] <> 0) |
|
403 |
or (p^[x * 3 + 1] <> 0) |
|
404 |
or (p^[x * 3 + 2] <> 0) then Land[cpY + y, cpX + x]:= COLOR_LAND; |
|
405 |
p:= @(p^[Image^.pitch]); |
|
406 |
end; |
|
407 |
4: for y:= 0 to Pred(h) do |
|
408 |
begin |
|
409 |
for x:= 0 to Pred(w) do |
|
410 |
if PLongword(@(p^[x * 4]))^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND; |
|
411 |
p:= @(p^[Image^.pitch]); |
|
412 |
end; |
|
413 |
end; |
|
414 |
if SDL_MustLock(Image) then |
|
415 |
SDL_UnlockSurface(Image); |
|
416 |
||
417 |
// Draw sprite on Land surface |
|
418 |
r.x:= 0; |
|
419 |
r.y:= SpritesData[Obj].Height * Frame; |
|
420 |
r.w:= SpritesData[Obj].Width; |
|
421 |
r.h:= SpritesData[Obj].Height; |
|
422 |
rr.x:= cpX; |
|
423 |
rr.y:= cpY; |
|
520 | 424 |
SDL_UpperBlit(Image, @r, LandSurface, @rr) |
409 | 425 |
end; |
426 |
||
184 | 427 |
|
428 |
end. |