0 | 0 |
/*
|
1 | |
# SUPER WUMPUS LAND v1.1-2013.0324
|
2 | |
# Copyright (c)2000-2013, Chris Pressey, Cat's Eye Technologies.
|
3 | |
# All rights reserved.
|
4 | |
#
|
5 | |
# Redistribution and use in source and binary forms, with or without
|
6 | |
# modification, are permitted provided that the following conditions
|
7 | |
# are met:
|
8 | |
#
|
9 | |
# 1. Redistributions of source code must retain the above copyright
|
10 | |
# notices, this list of conditions and the following disclaimer.
|
11 | |
# 2. Redistributions in binary form must reproduce the above copyright
|
12 | |
# notices, this list of conditions, and the following disclaimer in
|
13 | |
# the documentation and/or other materials provided with the
|
14 | |
# distribution.
|
15 | |
# 3. Neither the names of the copyright holders nor the names of their
|
16 | |
# contributors may be used to endorse or promote products derived
|
17 | |
# from this software without specific prior written permission.
|
18 | |
#
|
19 | |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20 | |
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
|
21 | |
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
22 | |
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 | |
# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
24 | |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
25 | |
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
26 | |
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
27 | |
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
28 | |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
29 | |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30 | |
# POSSIBILITY OF SUCH DAMAGE.
|
|
1 |
* SUPER WUMPUS LAND v1.1-2014.1024
|
|
2 |
* Copyright (c)2000-2014, Chris Pressey, Cat's Eye Technologies.
|
|
3 |
* All rights reserved.
|
|
4 |
*
|
|
5 |
* Redistribution and use in source and binary forms, with or without
|
|
6 |
* modification, are permitted provided that the following conditions
|
|
7 |
* are met:
|
|
8 |
*
|
|
9 |
* 1. Redistributions of source code must retain the above copyright
|
|
10 |
* notices, this list of conditions and the following disclaimer.
|
|
11 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
12 |
* notices, this list of conditions, and the following disclaimer in
|
|
13 |
* the documentation and/or other materials provided with the
|
|
14 |
* distribution.
|
|
15 |
* 3. Neither the names of the copyright holders nor the names of their
|
|
16 |
* contributors may be used to endorse or promote products derived
|
|
17 |
* from this software without specific prior written permission.
|
|
18 |
*
|
|
19 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20 |
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
|
|
21 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
22 |
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
23 |
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
24 |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
25 |
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
26 |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27 |
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
28 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
29 |
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
30 |
* POSSIBILITY OF SUCH DAMAGE.
|
31 | 31 |
*/
|
|
32 |
|
|
33 |
function launch(prefix, containerId) {
|
|
34 |
var deps = [
|
|
35 |
"playfield.js",
|
|
36 |
"cursor.js",
|
|
37 |
"playfield-canvas-view.js",
|
|
38 |
"text-terminal.js",
|
|
39 |
"line-input-buffer.js",
|
|
40 |
"element-factory.js"
|
|
41 |
];
|
|
42 |
var loaded = 0;
|
|
43 |
for (var i = 0; i < deps.length; i++) {
|
|
44 |
var elem = document.createElement('script');
|
|
45 |
elem.src = prefix + deps[i];
|
|
46 |
elem.onload = function() {
|
|
47 |
if (++loaded == deps.length) {
|
|
48 |
var container = document.getElementById(containerId);
|
|
49 |
var canvas = yoob.makeCanvas(container, 400, 400);
|
|
50 |
canvas.tabIndex = "0";
|
|
51 |
canvas.style.background = "black";
|
|
52 |
canvas.style.border = "5px solid black";
|
|
53 |
|
|
54 |
var t = new yoob.TextTerminal().init(80, 25);
|
|
55 |
var view = t.createPlayfieldCanvasView(canvas, 11, 18);
|
|
56 |
var swl = new SuperWumpusLand();
|
|
57 |
swl.init(t);
|
|
58 |
var ib = new yoob.LineInputBuffer().init(canvas, t);
|
|
59 |
ib.onupdate = function(str) {
|
|
60 |
view.draw();
|
|
61 |
};
|
|
62 |
ib.onenter = function(str) {
|
|
63 |
swl.handleInput(str);
|
|
64 |
view.draw();
|
|
65 |
};
|
|
66 |
view.draw();
|
|
67 |
canvas.focus();
|
|
68 |
}
|
|
69 |
};
|
|
70 |
document.body.appendChild(elem);
|
|
71 |
}
|
|
72 |
}
|
32 | 73 |
|
33 | 74 |
function d(n, s) {
|
34 | 75 |
var c = 0;
|
|
197 | 238 |
else if (i === 7)
|
198 | 239 |
print("* --------- ----------- ------- *\n");
|
199 | 240 |
else if (i === 9)
|
200 | |
print("* v1.1-2013.0324 *\n");
|
|
241 |
print("* v1.1-2014.1024 *\n");
|
201 | 242 |
else if (i === 10)
|
202 | 243 |
print("* (Javascript version) *\n");
|
203 | 244 |
else if (i === 14)
|