-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
190 lines (179 loc) · 5.04 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<html>
<head>
<title>Random Dungeon</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="tools">
<form>
<dl>
<dt>Size X</dt>
<dd>
<select name="sizeX">
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
<option value="60">60</option>
<option value="70">70</option>
</select>
</dd>
<dt>Size Y</dt>
<dd>
<select name="sizeY">
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
<option value="60">60</option>
<option value="70">70</option>
</select>
</dd>
<dt>Room Count</dt>
<dd>
<select name="roomCount">
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
<option value="45">45</option>
<option value="50">50</option>
</select>
</dd>
<dt>Room Min X</dt>
<dd>
<select name="roomMinX">
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</dd>
<dt>Room Min Y</dt>
<dd>
<select name="roomMinY">
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</dd>
<dt>Room Max X</dt>
<dd>
<select name="roomMaxX">
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
</dd>
<dt>Room Max Y</dt>
<dd>
<select name="roomMaxY">
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
</dd>
<dt>Keys</dt>
<dd>
<select name="keys">
<option value="0">None</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
</select>
</dd>
<dt>Number of Tries</dt>
<dd>
<select name="tries">
<option value="5">5</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="100" selected>100</option>
</select>
</dd>
</dl>
</form>
</div>
<div id="output_wrapper">
<input type="button" value="Generate" onclick="dungeonGenerate();" />
<input type="button" value="Cancel" onclick="dungeonCancel();" />
<div id="output"></div>
</div>
</body>
<script type="text/javascript" src="astar.js"></script>
<script type="text/javascript" src="dungeon.js"></script>
<script type="text/javascript">
var dungeon = new Dungeon;
function dungeonGenerate()
{
// its in the process, just wait a bit :P
if ( !dungeon.done && dungeon.working )
return;
var output = document.getElementById('output');
var form = document.getElementsByTagName('FORM')[0];
output.innerHTML = 'Generating...';
dungeon.setOptions(
{
doubled : true,
sizeX : getSelectedValue(form.sizeX),
sizeY : getSelectedValue(form.sizeY),
roomCount : getSelectedValue(form.roomCount),
roomMinX : getSelectedValue(form.roomMinX),
roomMinY : getSelectedValue(form.roomMinY),
roomMaxX : getSelectedValue(form.roomMaxX),
roomMaxY : getSelectedValue(form.roomMaxY),
keys : getSelectedValue(form.keys),
tries : getSelectedValue(form.tries)
});
dungeon.generate();
// checks on a interval to see if dungeon is complete
var setInt = setInterval(function()
{
if ( dungeon.done && !dungeon.working )
{
clearInterval(setInt);
dungeon.render('output');
// wtf!
var table = document.getElementById('grid');
table.style.width = 24 * table.getElementsByTagName('TR')[0].getElementsByTagName('TD').length;
}
if ( dungeon.cancelled )
{
clearInterval(setInt);
output.innerHTML = 'Cancelled';
}
}, 50);
}
function dungeonCancel()
{
dungeon.cancel();
}
function getSelectedValue(select)
{
return parseInt(select.options[select.selectedIndex].value)
}
</script>
</html>