author | alfadur |
Mon, 19 Dec 2016 12:34:09 -0500 | |
changeset 12117 | 2c21bca6cbfa |
parent 11709 | 1694b379c83f |
child 12316 | 1b5a4807f8f4 |
permissions | -rw-r--r-- |
10198 | 1 |
unit uLandUtils; |
2 |
interface |
|
3 |
||
4 |
procedure ResizeLand(width, height: LongWord); |
|
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
|
5 |
procedure InitWorldEdges(); |
10198 | 6 |
|
7 |
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
|
8 |
uses uUtils, uConsts, uVariables, uTypes; |
10198 | 9 |
|
10 |
procedure ResizeLand(width, height: LongWord); |
|
11 |
var potW, potH: LongInt; |
|
12 |
begin |
|
13 |
potW:= toPowerOf2(width); |
|
14 |
potH:= toPowerOf2(height); |
|
15 |
if (potW <> LAND_WIDTH) or (potH <> LAND_HEIGHT) then |
|
16 |
begin |
|
17 |
LAND_WIDTH:= potW; |
|
18 |
LAND_HEIGHT:= potH; |
|
19 |
LAND_WIDTH_MASK:= not(LAND_WIDTH-1); |
|
20 |
LAND_HEIGHT_MASK:= not(LAND_HEIGHT-1); |
|
21 |
cWaterLine:= LAND_HEIGHT; |
|
22 |
if (cReducedQuality and rqBlurryLand) = 0 then |
|
23 |
SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH) |
|
24 |
else |
|
25 |
SetLength(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2); |
|
26 |
||
27 |
SetLength(Land, LAND_HEIGHT, LAND_WIDTH); |
|
28 |
SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32)); |
|
29 |
// 0.5 is already approaching on unplayable |
|
10994 | 30 |
if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= cMaxZoomLevel/2; |
10198 | 31 |
cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel |
32 |
end; |
|
11709
1694b379c83f
fix clouds/flakes area not being adjusted after ResizeLand()
sheepluva
parents:
10994
diff
changeset
|
33 |
initScreenSpaceVars(); |
10198 | 34 |
end; |
35 |
||
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
|
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
|
43 |
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
|
44 |
|
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
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
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
|
51 |
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
|
52 |
|
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
|
53 |
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
|
54 |
|
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
|
55 |
// 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
|
56 |
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
|
57 |
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
|
58 |
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
|
59 |
for cy:= ly 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
|
60 |
if Land[cy, cx] <> 0 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
|
61 |
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
|
62 |
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
|
63 |
// 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
|
64 |
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
|
65 |
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
|
66 |
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
|
67 |
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
|
68 |
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
|
69 |
|
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
|
70 |
// 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
|
71 |
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
|
72 |
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
|
73 |
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
|
74 |
for cy:= ly 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
|
75 |
if Land[cy, cx] <> 0 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
|
76 |
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
|
77 |
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
|
78 |
// 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
|
79 |
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
|
80 |
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
|
81 |
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
|
82 |
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
|
83 |
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
|
84 |
|
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
|
85 |
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
|
86 |
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
|
87 |
|
10198 | 88 |
end. |