equal
deleted
inserted
replaced
1 unit uLandUtils; |
1 unit uLandUtils; |
2 interface |
2 interface |
3 |
3 |
4 procedure ResizeLand(width, height: LongWord); |
4 procedure ResizeLand(width, height: LongWord); |
|
5 procedure InitWorldEdges(); |
5 |
6 |
6 implementation |
7 implementation |
7 uses uUtils, uConsts, uVariables; |
8 uses uUtils, uConsts, uVariables, uTypes; |
8 |
9 |
9 procedure ResizeLand(width, height: LongWord); |
10 procedure ResizeLand(width, height: LongWord); |
10 var potW, potH: LongInt; |
11 var potW, potH: LongInt; |
11 begin |
12 begin |
12 potW:= toPowerOf2(width); |
13 potW:= toPowerOf2(width); |
29 if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= 0.5; |
30 if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= 0.5; |
30 cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel |
31 cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel |
31 end; |
32 end; |
32 end; |
33 end; |
33 |
34 |
|
35 procedure InitWorldEdges(); |
|
36 var cy, cx, lx, ly: LongInt; |
|
37 found: boolean; |
|
38 begin |
|
39 playHeight:= LAND_HEIGHT; |
|
40 topY:= 0; |
|
41 |
|
42 lx:= LongInt(LAND_WIDTH) - 1; |
|
43 |
|
44 if WorldEdge = weNone then |
|
45 begin |
|
46 playWidth:= LAND_WIDTH; |
|
47 leftX := 0; |
|
48 rightX:= lx; |
|
49 EXIT; |
|
50 end; |
|
51 |
|
52 ly:= LongInt(LAND_HEIGHT) - 1; |
|
53 |
|
54 // find most left land pixels and set leftX accordingly |
|
55 found:= false; |
|
56 for cx:= 0 to lx do |
|
57 begin |
|
58 for cy:= ly downto 0 do |
|
59 if Land[cy, cx] <> 0 then |
|
60 begin |
|
61 leftX:= max(0, cx - cWorldEdgeDist); |
|
62 // break out of both loops |
|
63 found:= true; |
|
64 break; |
|
65 end; |
|
66 if found then break; |
|
67 end; |
|
68 |
|
69 // find most right land pixels and set rightX accordingly |
|
70 found:= false; |
|
71 for cx:= lx downto 0 do |
|
72 begin |
|
73 for cy:= ly downto 0 do |
|
74 if Land[cy, cx] <> 0 then |
|
75 begin |
|
76 rightX:= min(lx, cx + cWorldEdgeDist); |
|
77 // break out of both loops |
|
78 found:= true; |
|
79 break; |
|
80 end; |
|
81 if found then break; |
|
82 end; |
|
83 |
|
84 playWidth := rightX + 1 - leftX; |
|
85 end; |
|
86 |
34 end. |
87 end. |