author | unc0rr |
Fri, 11 Jan 2008 22:47:54 +0000 | |
changeset 698 | 43f3ef079f53 |
parent 520 | e83dfb7ffead |
child 700 | be4847674071 |
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); |
|
698 | 225 |
|
226 |
LogLandDigest |
|
184 | 227 |
end; |
228 |
||
371 | 229 |
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); |
184 | 230 |
var tx, ty, i: LongInt; |
231 |
begin |
|
232 |
if SDL_MustLock(LandSurface) then |
|
233 |
SDL_LockSurface(LandSurface); |
|
234 |
||
235 |
for i:= 0 to Pred(Count) do |
|
236 |
begin |
|
188 | 237 |
for ty:= max(y - Radius, 0) to min(y + Radius, 1023) do |
351 | 238 |
for tx:= max(0, ar^[i].Left - Radius) to min(2047, ar^[i].Right + Radius) do |
188 | 239 |
ClearLandPixel(ty, tx); |
184 | 240 |
inc(y, dY) |
241 |
end; |
|
242 |
||
243 |
inc(Radius, 4); |
|
351 | 244 |
dec(y, Count * dY); |
184 | 245 |
|
246 |
for i:= 0 to Pred(Count) do |
|
247 |
begin |
|
188 | 248 |
for ty:= max(y - Radius, 0) to min(y + Radius, 1023) do |
351 | 249 |
for tx:= max(0, ar^[i].Left - Radius) to min(2047, ar^[i].Right + Radius) do |
188 | 250 |
if Land[ty, tx] = $FFFFFF then |
251 |
SetLandPixel(ty, tx); |
|
184 | 252 |
inc(y, dY) |
253 |
end; |
|
254 |
||
255 |
if SDL_MustLock(LandSurface) then |
|
256 |
SDL_UnlockSurface(LandSurface); |
|
257 |
end; |
|
258 |
||
259 |
// |
|
260 |
// - (dX, dY) - direction, vector of length = 0.5 |
|
261 |
// |
|
371 | 262 |
procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
358 | 263 |
var nx, ny, dX8, dY8: hwFloat; |
184 | 264 |
i, t, tx, ty: Longint; |
265 |
begin // (-dY, dX) is (dX, dY) rotated by PI/2 |
|
266 |
if SDL_MustLock(LandSurface) then |
|
267 |
SDL_LockSurface(LandSurface); |
|
268 |
||
269 |
nx:= X + dY * (HalfWidth + 8); |
|
270 |
ny:= Y - dX * (HalfWidth + 8); |
|
271 |
||
358 | 272 |
dX8:= dX * 8; |
273 |
dY8:= dY * 8; |
|
184 | 274 |
for i:= 0 to 7 do |
275 |
begin |
|
358 | 276 |
X:= nx - dX8; |
277 |
Y:= ny - dY8; |
|
184 | 278 |
for t:= -8 to ticks + 8 do |
279 |
{$include tunsetborder.inc} |
|
280 |
nx:= nx - dY; |
|
281 |
ny:= ny + dX; |
|
282 |
end; |
|
283 |
||
284 |
for i:= -HalfWidth to HalfWidth do |
|
285 |
begin |
|
358 | 286 |
X:= nx - dX8; |
287 |
Y:= ny - dY8; |
|
184 | 288 |
for t:= 0 to 7 do |
289 |
{$include tunsetborder.inc} |
|
290 |
X:= nx; |
|
291 |
Y:= ny; |
|
292 |
for t:= 0 to ticks do |
|
293 |
begin |
|
294 |
X:= X + dX; |
|
295 |
Y:= Y + dY; |
|
351 | 296 |
tx:= hwRound(X); |
297 |
ty:= hwRound(Y); |
|
184 | 298 |
if ((ty and $FFFFFC00) = 0) and ((tx and $FFFFF800) = 0) then |
511 | 299 |
if Land[ty, tx] = COLOR_LAND then |
184 | 300 |
begin |
301 |
Land[ty, tx]:= 0; |
|
302 |
ClearLandPixel(ty, tx); |
|
303 |
end |
|
304 |
end; |
|
305 |
for t:= 0 to 7 do |
|
306 |
{$include tunsetborder.inc} |
|
307 |
nx:= nx - dY; |
|
308 |
ny:= ny + dX; |
|
309 |
end; |
|
310 |
||
311 |
for i:= 0 to 7 do |
|
312 |
begin |
|
358 | 313 |
X:= nx - dX8; |
314 |
Y:= ny - dY8; |
|
184 | 315 |
for t:= -8 to ticks + 8 do |
316 |
{$include tunsetborder.inc} |
|
317 |
nx:= nx - dY; |
|
318 |
ny:= ny + dX; |
|
319 |
end; |
|
320 |
||
321 |
if SDL_MustLock(LandSurface) then |
|
322 |
SDL_UnlockSurface(LandSurface) |
|
323 |
end; |
|
324 |
||
520 | 325 |
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean; |
495 | 326 |
var X, Y, bpp, h, w: LongInt; |
409 | 327 |
p: PByteArray; |
328 |
r, rr: TSDL_Rect; |
|
329 |
Image: PSDL_Surface; |
|
330 |
begin |
|
331 |
Image:= SpritesData[Obj].Surface; |
|
332 |
w:= SpritesData[Obj].Width; |
|
333 |
h:= SpritesData[Obj].Height; |
|
334 |
||
335 |
if SDL_MustLock(Image) then |
|
336 |
SDLTry(SDL_LockSurface(Image) >= 0, true); |
|
337 |
||
338 |
bpp:= Image^.format^.BytesPerPixel; |
|
339 |
TryDo(bpp <> 1, 'We don''t work with 8 bit surfaces', true); |
|
340 |
// Check that sprites fits free space |
|
341 |
p:= @(PByteArray(Image^.pixels)^[Image^.pitch * Frame * h]); |
|
342 |
case bpp of |
|
343 |
2: for y:= 0 to Pred(h) do |
|
344 |
begin |
|
345 |
for x:= 0 to Pred(w) do |
|
346 |
if PWord(@(p^[x * 2]))^ <> 0 then |
|
347 |
if (((cpY + y) and $FFFFFC00) <> 0) or |
|
348 |
(((cpX + x) and $FFFFF800) <> 0) or |
|
349 |
(Land[cpY + y, cpX + x] <> 0) then |
|
350 |
begin |
|
351 |
if SDL_MustLock(Image) then |
|
352 |
SDL_UnlockSurface(Image); |
|
353 |
exit(false) |
|
354 |
end; |
|
355 |
p:= @(p^[Image^.pitch]); |
|
356 |
end; |
|
357 |
3: for y:= 0 to Pred(h) do |
|
358 |
begin |
|
359 |
for x:= 0 to Pred(w) do |
|
360 |
if (p^[x * 3 + 0] <> 0) |
|
361 |
or (p^[x * 3 + 1] <> 0) |
|
362 |
or (p^[x * 3 + 2] <> 0) then |
|
363 |
if (((cpY + y) and $FFFFFC00) <> 0) or |
|
364 |
(((cpX + x) and $FFFFF800) <> 0) or |
|
365 |
(Land[cpY + y, cpX + x] <> 0) then |
|
366 |
begin |
|
367 |
if SDL_MustLock(Image) then |
|
368 |
SDL_UnlockSurface(Image); |
|
369 |
exit(false) |
|
370 |
end; |
|
371 |
p:= @(p^[Image^.pitch]); |
|
372 |
end; |
|
373 |
4: for y:= 0 to Pred(h) do |
|
374 |
begin |
|
375 |
for x:= 0 to Pred(w) do |
|
376 |
if PLongword(@(p^[x * 4]))^ <> 0 then |
|
377 |
if (((cpY + y) and $FFFFFC00) <> 0) or |
|
378 |
(((cpX + x) and $FFFFF800) <> 0) or |
|
379 |
(Land[cpY + y, cpX + x] <> 0) then |
|
380 |
begin |
|
381 |
if SDL_MustLock(Image) then |
|
382 |
SDL_UnlockSurface(Image); |
|
383 |
exit(false) |
|
384 |
end; |
|
385 |
p:= @(p^[Image^.pitch]); |
|
386 |
end; |
|
387 |
end; |
|
388 |
||
520 | 389 |
TryPlaceOnLand:= true; |
390 |
if not doPlace then exit; |
|
391 |
||
409 | 392 |
// Checked, now place |
393 |
p:= @(PByteArray(Image^.pixels)^[Image^.pitch * Frame * h]); |
|
394 |
case bpp of |
|
395 |
2: for y:= 0 to Pred(h) do |
|
396 |
begin |
|
397 |
for x:= 0 to Pred(w) do |
|
398 |
if PWord(@(p^[x * 2]))^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND; |
|
399 |
p:= @(p^[Image^.pitch]); |
|
400 |
end; |
|
401 |
3: for y:= 0 to Pred(h) do |
|
402 |
begin |
|
403 |
for x:= 0 to Pred(w) do |
|
404 |
if (p^[x * 3 + 0] <> 0) |
|
405 |
or (p^[x * 3 + 1] <> 0) |
|
406 |
or (p^[x * 3 + 2] <> 0) then Land[cpY + y, cpX + x]:= COLOR_LAND; |
|
407 |
p:= @(p^[Image^.pitch]); |
|
408 |
end; |
|
409 |
4: for y:= 0 to Pred(h) do |
|
410 |
begin |
|
411 |
for x:= 0 to Pred(w) do |
|
412 |
if PLongword(@(p^[x * 4]))^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND; |
|
413 |
p:= @(p^[Image^.pitch]); |
|
414 |
end; |
|
415 |
end; |
|
416 |
if SDL_MustLock(Image) then |
|
417 |
SDL_UnlockSurface(Image); |
|
418 |
||
419 |
// Draw sprite on Land surface |
|
420 |
r.x:= 0; |
|
421 |
r.y:= SpritesData[Obj].Height * Frame; |
|
422 |
r.w:= SpritesData[Obj].Width; |
|
423 |
r.h:= SpritesData[Obj].Height; |
|
424 |
rr.x:= cpX; |
|
425 |
rr.y:= cpY; |
|
520 | 426 |
SDL_UpperBlit(Image, @r, LandSurface, @rr) |
409 | 427 |
end; |
428 |
||
184 | 429 |
|
430 |
end. |