author | sheepluva |
Tue, 10 Nov 2015 17:45:14 +0100 | |
branch | sdl2transition |
changeset 11360 | 7a7611adf715 |
parent 7791 | b937274608ba |
child 10153 | 28e53573fdd2 |
permissions | -rw-r--r-- |
7785
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
1 |
PointsBuffer = '' -- A string to accumulate points in |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
2 |
function AddPoint(x, y, width, erase) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
3 |
PointsBuffer = PointsBuffer .. string.char(band(x,0xff00) / 256 , band(x,0xff) , band(y,0xff00) / 256 , band(y,0xff)) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
4 |
if width then |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
5 |
width = bor(width,0x80) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
6 |
if erase then |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
7 |
width = bor(width,0x40) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
8 |
end |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
9 |
PointsBuffer = PointsBuffer .. string.char(width) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
10 |
else |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
11 |
PointsBuffer = PointsBuffer .. string.char(0) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
12 |
end |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
13 |
if #PointsBuffer > 245 then |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
14 |
ParseCommand('draw '..PointsBuffer) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
15 |
PointsBuffer = '' |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
16 |
end |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
17 |
end |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
18 |
function FlushPoints() |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
19 |
if #PointsBuffer > 0 then |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
20 |
ParseCommand('draw '..PointsBuffer) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
21 |
PointsBuffer = '' |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
22 |
end |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
23 |
end |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
24 |
|
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
25 |
|
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
26 |
function onGameInit() |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
27 |
MapGen = 2 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
28 |
TemplateFilter = 0 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
29 |
for i = 200,2000,600 do |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
30 |
AddPoint(1,i,63) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
31 |
AddPoint(4000,i) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
32 |
end |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
33 |
|
7791
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
34 |
side = 0 |
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
35 |
for i = 0,GetRandom(15)+25 do |
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
36 |
if side > 3 then |
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
37 |
size = GetRandom(4)+4 |
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
38 |
else |
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
39 |
size = GetRandom(12)+4 |
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
40 |
end |
7785
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
41 |
--side = GetRandom(4) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
42 |
dx = div(size,4) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
43 |
maxshift = dx |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
44 |
dy = dx |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
45 |
if side == 0 then |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
46 |
x = 0 |
7791
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
47 |
y = GetRandom(2048-size*4)+size*2 |
7785
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
48 |
dy = 0 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
49 |
elseif side == 1 then |
7791
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
50 |
x = GetRandom(4096-size*4)+size*2 |
7785
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
51 |
y = 0 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
52 |
dx = 0 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
53 |
elseif side == 2 then |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
54 |
x = 4096 |
7791
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
55 |
y = GetRandom(2048-size*4)+size*2 |
7785
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
56 |
dx = -dx |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
57 |
dy = 0 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
58 |
elseif side == 3 then |
7791
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
59 |
x = GetRandom(4096-size*4)+size*2 |
7785
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
60 |
y = 2048 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
61 |
dx = 0 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
62 |
dy = -dy |
7791
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
63 |
elseif side > 3 then |
7785
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
64 |
x = GetRandom(2500)+500 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
65 |
y = GetRandom(1250)+250 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
66 |
dx = GetRandom(maxshift*2)-maxshift |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
67 |
dy = GetRandom(maxshift*2)-maxshift |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
68 |
end |
7791
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
69 |
length = GetRandom(500-size*25)+600 |
7785
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
70 |
while (length > 0) and (x > -300) and (y > -300) and (x < 4400) and (y < 2400) do |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
71 |
length = length - 1 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
72 |
AddPoint(x,y,size,true) |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
73 |
x = x + dx |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
74 |
y = y + dy |
7791
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
75 |
if GetRandom(8) == 0 then |
7785
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
76 |
shift = GetRandom(10)-5 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
77 |
if (shift > 0) and (dx < maxshift) then |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
78 |
dx = dx + shift |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
79 |
elseif (shift < 0) and (dx > -maxshift) then |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
80 |
dx = dx + shift |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
81 |
end |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
82 |
shift = GetRandom(10)-5 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
83 |
if (shift > 0) and (dy < maxshift) then |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
84 |
dy = dy + shift |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
85 |
elseif (shift < 0) and (dy > -maxshift) then |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
86 |
dy = dy + shift |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
87 |
end |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
88 |
end |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
89 |
end |
7791
b937274608ba
Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents:
7785
diff
changeset
|
90 |
if side < 6 then |
7785
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
91 |
side = side + 1 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
92 |
else |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
93 |
side = 0 |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
94 |
end |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
95 |
end |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
96 |
|
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
97 |
FlushPoints() |
9b5dceaea976
Someone should look this over to make sure it should stay in
nemo
parents:
diff
changeset
|
98 |
end |