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