author | wuzzy |
Sun, 21 Dec 2014 09:27:57 +0100 | |
changeset 10698 | aa3dfb4df603 |
parent 10626 | 2562797ab3cf |
child 10994 | cd7f918eed30 |
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 |
|
30 |
if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= 0.5; |
|
31 |
cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel |
|
32 |
end; |
|
33 |
end; |
|
34 |
||
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
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
|
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 |
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
|
43 |
|
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 |
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
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
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
|
51 |
|
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 |
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
|
53 |
|
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 |
// 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
|
55 |
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
|
56 |
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
|
57 |
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
|
58 |
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
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
// 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
|
63 |
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
|
64 |
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
|
65 |
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
|
66 |
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
|
67 |
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
|
68 |
|
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 |
// 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
|
70 |
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
|
71 |
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
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
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
|
76 |
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
|
77 |
// 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
|
78 |
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
|
79 |
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
|
80 |
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
|
81 |
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
|
82 |
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
|
83 |
|
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 |
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
|
85 |
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
|
86 |
|
10198 | 87 |
end. |