author | unC0Rr |
Wed, 04 Jan 2023 15:26:30 +0100 | |
branch | transitional_engine |
changeset 15935 | b4809653f9d6 |
parent 15934 | 022ec6b916b7 |
child 15958 | 772a43d88e6b |
permissions | -rw-r--r-- |
10198 | 1 |
unit uLandUtils; |
2 |
interface |
|
15930
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
3 |
uses SDLh; |
10198 | 4 |
|
15934
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
5 |
procedure GenerateTemplatedLand(featureSize: Longword; seed, templateType, dataPath: shortstring); |
10198 | 6 |
procedure ResizeLand(width, height: LongWord); |
15929
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
7 |
procedure DisposeLand(); |
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
8 |
procedure InitWorldEdges(); |
10198 | 9 |
|
15929
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
10 |
function LandGet(y, x: LongInt): Word; |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
11 |
procedure LandSet(y, x: LongInt; value: Word); |
15930
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
12 |
function LandRow(row: LongInt): PWordArray; |
15929
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
13 |
|
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
14 |
procedure FillLand(x, y: LongInt; border, value: Word); |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
15 |
|
15930
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
16 |
function LandPixelGet(y, x: LongInt): Longword; |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
17 |
procedure LandPixelSet(y, x: LongInt; value: Longword); |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
18 |
function LandPixelRow(row: LongInt): PLongwordArray; |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
19 |
|
10198 | 20 |
implementation |
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
21 |
uses uUtils, uConsts, uVariables, uTypes; |
10198 | 22 |
|
15929
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
23 |
const LibFutureName = 'hwengine_future'; |
15933 | 24 |
|
25 |
function create_empty_game_field(width, height: Longword): pointer; cdecl; external LibFutureName; |
|
15934
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
26 |
procedure get_game_field_parameters(game_field: pointer; var width: LongInt; var height: LongInt; var play_width: LongInt; var play_height: LongInt); cdecl; external LibFutureName; |
15929
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
27 |
procedure dispose_game_field(game_field: pointer); cdecl; external LibFutureName; |
15933 | 28 |
|
15929
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
29 |
function land_get(game_field: pointer; x, y: LongInt): Word; cdecl; external LibFutureName; |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
30 |
procedure land_set(game_field: pointer; x, y: LongInt; value: Word); cdecl; external LibFutureName; |
15930
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
31 |
function land_row(game_field: pointer; row: LongInt): PWordArray; cdecl; external LibFutureName; |
15929
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
32 |
procedure land_fill(game_field: pointer; x, y: LongInt; border, fill: Word); cdecl; external LibFutureName; |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
33 |
|
15930
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
34 |
function land_pixel_get(game_field: pointer; x, y: LongInt): Longword; cdecl; external LibFutureName; |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
35 |
procedure land_pixel_set(game_field: pointer; x, y: LongInt; value: Longword); cdecl; external LibFutureName; |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
36 |
function land_pixel_row(game_field: pointer; row: LongInt): PLongwordArray; cdecl; external LibFutureName; |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
37 |
|
15934
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
38 |
function generate_templated_game_field(feature_size: Longword; seed, template_type, data_path: PChar): pointer; cdecl; external LibFutureName; |
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
39 |
procedure apply_theme(game_field: pointer; data_path, theme_name: PChar); cdecl; external LibFutureName; |
15933 | 40 |
|
15929
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
41 |
var gameField: pointer; |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
42 |
|
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
43 |
function LandGet(y, x: LongInt): Word; |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
44 |
begin |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
45 |
LandGet:= land_get(gameField, x, y) |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
46 |
end; |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
47 |
|
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
48 |
procedure LandSet(y, x: LongInt; value: Word); |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
49 |
begin |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
50 |
land_set(gameField, x, y, value) |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
51 |
end; |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
52 |
|
15930
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
53 |
function LandRow(row: LongInt): PWordArray; |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
54 |
begin |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
55 |
LandRow:= land_row(gameField, row) |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
56 |
end; |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
57 |
|
15929
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
58 |
procedure FillLand(x, y: LongInt; border, value: Word); |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
59 |
begin |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
60 |
land_fill(gameField, x, y, border, value) |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
61 |
end; |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
62 |
|
15930
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
63 |
function LandPixelGet(y, x: LongInt): Longword; |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
64 |
begin |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
65 |
LandPixelGet:= land_pixel_get(gameField, x, y) |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
66 |
end; |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
67 |
|
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
68 |
procedure LandPixelSet(y, x: LongInt; value: Longword); |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
69 |
begin |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
70 |
land_pixel_set(gameField, x, y, value) |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
71 |
end; |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
72 |
|
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
73 |
function LandPixelRow(row: LongInt): PLongwordArray; |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
74 |
begin |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
75 |
LandPixelRow:= land_pixel_row(gameField, row) |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
76 |
end; |
f39f0f614dbf
Use LandPixels array allocate in hwengine-future library
unC0Rr
parents:
15929
diff
changeset
|
77 |
|
15934
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
78 |
procedure GenerateTemplatedLand(featureSize: Longword; seed, templateType, dataPath: shortstring); |
15933 | 79 |
begin |
80 |
seed[byte(seed[0]) + 1]:= #0; |
|
15934
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
81 |
templateType[byte(templateType[0]) + 1]:= #0; |
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
82 |
|
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
83 |
gameField:= generate_templated_game_field(featureSize, @seed[1], @templateType[1], Str2PChar(dataPath)); |
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
84 |
get_game_field_parameters(gameField, LAND_WIDTH, LAND_HEIGHT, playWidth, playHeight); |
15933 | 85 |
|
15934
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
86 |
MaxHedgehogs:= 32; |
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
87 |
hasGirders:= true; |
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
88 |
|
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
89 |
leftX:= (LAND_WIDTH - playWidth) div 2; |
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
90 |
rightX:= Pred(leftX + playWidth); |
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
91 |
topY:= LAND_HEIGHT - playHeight; |
022ec6b916b7
Split generation and painting phases, paint by old engine, use template filters
unC0Rr
parents:
15933
diff
changeset
|
92 |
|
15933 | 93 |
|
94 |
// let's assume those are powers of two |
|
95 |
LAND_WIDTH_MASK:= not(LAND_WIDTH-1); |
|
96 |
LAND_HEIGHT_MASK:= not(LAND_HEIGHT-1); |
|
97 |
||
98 |
SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32)); |
|
99 |
||
100 |
initScreenSpaceVars(); |
|
101 |
end; |
|
102 |
||
10198 | 103 |
procedure ResizeLand(width, height: LongWord); |
104 |
var potW, potH: LongInt; |
|
105 |
begin |
|
106 |
potW:= toPowerOf2(width); |
|
107 |
potH:= toPowerOf2(height); |
|
108 |
if (potW <> LAND_WIDTH) or (potH <> LAND_HEIGHT) then |
|
109 |
begin |
|
110 |
LAND_WIDTH:= potW; |
|
111 |
LAND_HEIGHT:= potH; |
|
112 |
LAND_WIDTH_MASK:= not(LAND_WIDTH-1); |
|
113 |
LAND_HEIGHT_MASK:= not(LAND_HEIGHT-1); |
|
114 |
cWaterLine:= LAND_HEIGHT; |
|
115 |
||
15933 | 116 |
gameField:= create_empty_game_field(LAND_WIDTH, LAND_HEIGHT); |
10198 | 117 |
SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32)); |
118 |
// 0.5 is already approaching on unplayable |
|
10994 | 119 |
if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= cMaxZoomLevel/2; |
10198 | 120 |
cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel |
121 |
end; |
|
11704
1694b379c83f
fix clouds/flakes area not being adjusted after ResizeLand()
sheepluva
parents:
10994
diff
changeset
|
122 |
initScreenSpaceVars(); |
10198 | 123 |
end; |
124 |
||
15929
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
125 |
procedure DisposeLand(); |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
126 |
begin |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
127 |
dispose_game_field(gameField) |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
128 |
end; |
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
129 |
|
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
130 |
procedure InitWorldEdges(); |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
131 |
var cy, cx, lx, ly: LongInt; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
132 |
found: boolean; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
133 |
begin |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
134 |
playHeight:= LAND_HEIGHT; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
135 |
topY:= 0; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
136 |
|
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
137 |
lx:= LongInt(LAND_WIDTH) - 1; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
138 |
|
15164
794dc7237ca1
Fix world edge positions for drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
12311
diff
changeset
|
139 |
// don't change world edges for drawn maps |
794dc7237ca1
Fix world edge positions for drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
12311
diff
changeset
|
140 |
if (cMapGen = mgDrawn) then |
794dc7237ca1
Fix world edge positions for drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
12311
diff
changeset
|
141 |
// edges were adjusted already in GenDrawnMap() in uLand |
794dc7237ca1
Fix world edge positions for drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
12311
diff
changeset
|
142 |
EXIT; |
794dc7237ca1
Fix world edge positions for drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents:
12311
diff
changeset
|
143 |
|
12311
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11704
diff
changeset
|
144 |
// use maximum available map width if there is no special world edge |
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
145 |
if WorldEdge = weNone then |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
146 |
begin |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
147 |
playWidth:= LAND_WIDTH; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
148 |
leftX := 0; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
149 |
rightX:= lx; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
150 |
EXIT; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
151 |
end; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
152 |
|
12311
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11704
diff
changeset
|
153 |
// keep fort distance consistent if we're in wrap mode on fort map |
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11704
diff
changeset
|
154 |
if (cMapGen = mgForts) and (WorldEdge = weWrap) then |
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11704
diff
changeset
|
155 |
begin |
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11704
diff
changeset
|
156 |
// edges were adjusted already in MakeFortsMap() in uLand |
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11704
diff
changeset
|
157 |
EXIT; |
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11704
diff
changeset
|
158 |
end; |
1b5a4807f8f4
fix fort mode's edge adjustments getting lost with weWrap. issue #181
sheepluva
parents:
11704
diff
changeset
|
159 |
|
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
160 |
ly:= LongInt(LAND_HEIGHT) - 1; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
161 |
|
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
162 |
// find most left land pixels and set leftX accordingly |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
163 |
found:= false; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
164 |
for cx:= 0 to lx do |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
165 |
begin |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
166 |
for cy:= ly downto 0 do |
15929
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
167 |
if LandGet(cy, cx) <> 0 then |
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
168 |
begin |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
169 |
leftX:= max(0, cx - cWorldEdgeDist); |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
170 |
// break out of both loops |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
171 |
found:= true; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
172 |
break; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
173 |
end; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
174 |
if found then break; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
175 |
end; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
176 |
|
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
177 |
// find most right land pixels and set rightX accordingly |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
178 |
found:= false; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
179 |
for cx:= lx downto 0 do |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
180 |
begin |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
181 |
for cy:= ly downto 0 do |
15929
128ace913837
Introduce hwengine-future library, use Land allocated in it
unC0Rr
parents:
15164
diff
changeset
|
182 |
if LandGet(cy, cx) <> 0 then |
10626
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
183 |
begin |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
184 |
rightX:= min(lx, cx + cWorldEdgeDist); |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
185 |
// break out of both loops |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
186 |
found:= true; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
187 |
break; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
188 |
end; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
189 |
if found then break; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
190 |
end; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
191 |
|
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
192 |
playWidth := rightX + 1 - leftX; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
193 |
end; |
2562797ab3cf
adjust position of world edges (at 150 px away from outmost land collision, or less if land array ends earlier)
sheepluva
parents:
10198
diff
changeset
|
194 |
|
10198 | 195 |
end. |