git @ Cat's Eye Technologies Super-Wumpus-Land / rel_1_1_2014_1024
Use the newly-developed-for-gewgaws dependency-loading scheme. Chris Pressey 8 years ago
3 changed file(s) with 148 addition(s) and 56 deletion(s). Raw diff Collapse all Expand all
22 <meta charset="utf-8">
33 <title>SUPER WUMPUS LAND</title>
44 <style>
5 #terminal {
6 background: black;
7 border: 5px solid black;
5 canvas { border: 1px solid blue; }
6 #container {
7 width: 100%;
8 text-align: center;
89 }
910 </style>
1011 </head>
1213
1314 <h1>SUPER WUMPUS LAND</h1>
1415
15 <canvas id="terminal" width="400" height="400" tabindex="0">
16 Your browser doesn't support displaying an HTML5 canvas.
17 </canvas>
16 <div id="container"></div>
1817
1918 </body>
20 <script src="../src/yoob/playfield.js"></script>
21 <script src="../src/yoob/cursor.js"></script>
22 <script src="../src/yoob/playfield-html-view.js"></script>
23 <script src="../src/yoob/playfield-canvas-view.js"></script>
24 <script src="../src/yoob/text-terminal.js"></script>
25 <script src="../src/yoob/line-input-buffer.js"></script>
2619 <script src="../src/swl.js"></script>
2720 <script>
28 var element = document.getElementById('terminal');
29 var t = new yoob.TextTerminal().init(80, 25);
30 var view = t.createPlayfieldCanvasView(element, 11, 18);
31 var swl = new SuperWumpusLand();
32 swl.init(t);
33 var ib = new yoob.LineInputBuffer().init(element, t);
34 ib.onupdate = function(str) { view.draw(); };
35 ib.onenter = function(str) {
36 swl.handleInput(str);
37 view.draw();
38 };
39 view.draw();
40 element.focus();
21 launch('../src/yoob/', 'container');
4122 </script>
00 /*
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.
3131 */
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 }
3273
3374 function d(n, s) {
3475 var c = 0;
197238 else if (i === 7)
198239 print("* --------- ----------- ------- *\n");
199240 else if (i === 9)
200 print("* v1.1-2013.0324 *\n");
241 print("* v1.1-2014.1024 *\n");
201242 else if (i === 10)
202243 print("* (Javascript version) *\n");
203244 else if (i === 14)
0 /*
1 * This file is part of yoob.js version 0.7-PRE
2 * Available from https://github.com/catseye/yoob.js/
3 * This file is in the public domain. See http://unlicense.org/ for details.
4 */
5 if (window.yoob === undefined) yoob = {};
6
7 /*
8 * Functions for creating elements.
9 *
10 * I dunno -- maybe just setting innerHTML would be better.
11 */
12
13 yoob.makeCanvas = function(container, width, height) {
14 var canvas = document.createElement('canvas');
15 if (width) {
16 canvas.width = width;
17 }
18 if (height) {
19 canvas.height = height;
20 }
21 container.appendChild(canvas);
22 return canvas;
23 };
24
25 yoob.makeButton = function(container, label) {
26 var button = document.createElement('button');
27 button.innerHTML = label;
28 container.appendChild(button);
29 return button;
30 };
31
32 yoob.checkBoxNumber = 0;
33 yoob.makeCheckbox = function(container, checked, labelText, fun) {
34 var checkbox = document.createElement('input');
35 checkbox.type = "checkbox";
36 checkbox.id = 'cfzzzb_' + yoob.checkBoxNumber;
37 checkbox.checked = checked;
38 var label = document.createElement('label');
39 label.htmlFor = 'cfzzzb_' + yoob.checkBoxNumber;
40 yoob.checkBoxNumber += 1;
41 label.appendChild(document.createTextNode(labelText));
42
43 container.appendChild(checkbox);
44 container.appendChild(label);
45
46 if (fun) {
47 checkbox.onchange = function(e) {
48 fun(checkbox.checked);
49 }
50 }
51 return checkbox;
52 };
53
54 yoob.makeSlider = function(container, min, max, value) {
55 var slider = document.createElement('input');
56 slider.type = "range";
57 slider.min = min;
58 slider.max = max;
59 slider.value = value;
60 container.appendChild(slider);
61 return slider;
62 };
63
64 yoob.makeParagraph = function(container, innerHTML) {
65 var p = document.createElement('p');
66 p.innerHTML = innerHTML;
67 container.appendChild(p);
68 return p;
69 };