changeset 4367 | f4a0ec067601 |
parent 4359 | 83ef50815535 |
child 4368 | b89235e401e5 |
4365:4f2b1a152979 | 4367:f4a0ec067601 |
---|---|
18 |
18 |
19 {$INCLUDE "options.inc"} |
19 {$INCLUDE "options.inc"} |
20 |
20 |
21 unit uLand; |
21 unit uLand; |
22 interface |
22 interface |
23 uses SDLh, uLandTemplates, uFloat, uConsts, GLunit; |
23 uses SDLh, uLandTemplates, uFloat, uConsts, GLunit, uTypes; |
24 |
|
25 type |
|
26 TLandArray = packed array of array of LongWord; |
|
27 TCollisionArray = packed array of array of Word; |
|
28 TPreview = packed array[0..127, 0..31] of byte; |
|
29 TDirtyTag = packed array of array of byte; |
|
30 |
|
31 var Land: TCollisionArray; |
|
32 LandPixels: TLandArray; |
|
33 LandDirty: TDirtyTag; |
|
34 hasBorder: boolean; |
|
35 hasGirders: boolean; |
|
36 isMap: boolean; |
|
37 playHeight, playWidth, leftX, rightX, topY, MaxHedgehogs: Longword; // idea is that a template can specify height/width. Or, a map, a height/width by the dimensions of the image. If the map has pixels near top of image, it triggers border. |
|
38 LandBackSurface: PSDL_Surface; |
|
39 digest: shortstring; |
|
40 |
24 |
41 type direction = record x, y: LongInt; end; |
25 type direction = record x, y: LongInt; end; |
42 const DIR_N: direction = (x: 0; y: -1); |
26 const DIR_N: direction = (x: 0; y: -1); |
43 DIR_E: direction = (x: 1; y: 0); |
27 DIR_E: direction = (x: 1; y: 0); |
44 DIR_S: direction = (x: 0; y: 1); |
28 DIR_S: direction = (x: 0; y: 1); |
47 procedure initModule; |
31 procedure initModule; |
48 procedure freeModule; |
32 procedure freeModule; |
49 procedure GenMap; |
33 procedure GenMap; |
50 function GenPreview: TPreview; |
34 function GenPreview: TPreview; |
51 procedure CheckLandDigest(s: shortstring); |
35 procedure CheckLandDigest(s: shortstring); |
52 function LandBackPixel(x, y: LongInt): LongWord; |
|
53 |
36 |
54 implementation |
37 implementation |
55 uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, Adler32, uIO, uLandTexture, sysutils, |
38 uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, Adler32, uIO, uLandTexture, sysutils, |
56 uTypes, uVariables; |
39 uVariables; |
57 |
40 |
58 operator=(const a, b: direction) c: Boolean; |
41 operator=(const a, b: direction) c: Boolean; |
59 begin |
42 begin |
60 c := (a.x = b.x) and (a.y = b.y); |
43 c := (a.x = b.x) and (a.y = b.y); |
61 end; |
44 end; |
316 Push(x, Pred(xl), y, dir); |
299 Push(x, Pred(xl), y, dir); |
317 Push(x, Pred(xl), y,-dir); |
300 Push(x, Pred(xl), y,-dir); |
318 end; |
301 end; |
319 end; |
302 end; |
320 end; |
303 end; |
321 end; |
|
322 |
|
323 function LandBackPixel(x, y: LongInt): LongWord; |
|
324 var p: PLongWordArray; |
|
325 begin |
|
326 if LandBackSurface = nil then LandBackPixel:= 0 |
|
327 else |
|
328 begin |
|
329 p:= LandBackSurface^.pixels; |
|
330 LandBackPixel:= p^[LandBackSurface^.w * (y mod LandBackSurface^.h) + (x mod LandBackSurface^.w)];// or $FF000000; |
|
331 end |
|
332 end; |
304 end; |
333 |
305 |
334 procedure ColorizeLand(Surface: PSDL_Surface); |
306 procedure ColorizeLand(Surface: PSDL_Surface); |
335 var tmpsurf: PSDL_Surface; |
307 var tmpsurf: PSDL_Surface; |
336 r, rr: TSDL_Rect; |
308 r, rr: TSDL_Rect; |