-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
173 lines (154 loc) · 7.42 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
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>The Legend of Canvassa [v0.5]</title>
<link rel="icon" type="image/vnd.microsoft.icon" href="http://www.buyog.com/code/loc/favicon.ico"/>
<link rel='stylesheet' href='loc.css'/>
<script>
var basePath = window.location.href.match(/(.*)\//)[0] + "loc";
var djConfig = { isDebug:false, modulePaths:{ "loc": basePath } };
</script>
<script type="text/javascript" src="http://o.aolcdn.com/dojo/1.4/dojo/dojo.js"></script>
<!--<script type="text/javascript" src="../dojo.js"></script>-->
<script type="text/javascript" src="../../sndmgr/script/soundmanager2-nodebug-jsmin.js"></script>
<!--[if IE]>
<script type="text/javascript" src="http://pipes.yahoo.com/js/excanvas.js"></script>
<![endif]-->
<script type="text/javascript">
// before ANYTHING else, see if we can get a canvas context
dojo.addOnLoad(function init_loader(){
window.map_canvas = dojo.byId('map');
window.sprite_canvas = dojo.byId('sprites');
if ('getContext' in map_canvas && map_canvas.getContext){
dojo.require("loc.Preloader");
dojo.addOnLoad(preload);
} else {
dojo.style("throbber", "display", "none")
}
}); // end of init_loader()
function preload() {
window.loader = new loc.Preloader({
images: {
title: "loc/res/title.png",
select: "loc/res/select.png",
font: "loc/res/font.png",
HUD: "loc/res/hud.png",
tiles: "loc/res/overworld_tiles.png",
link: "loc/res/link.png",
items: "loc/res/items.png",
monsters: "loc/res/monsters.png"
},
modules: ["loc.Sounds","loc.Game"]
})
if (loader.ready()) {
init_game();
delete window.loader;
} else {
// show "please wait" throbber
dojo.style("throbber","display","none");
var listener = dojo.subscribe("loc.Preloader.onReady", function() {
dojo.unsubscribe(listener);
init_game();
delete window.loader;
});
}
} // end of preload()
function init_game() {
var scale = 1;
window.game = new loc.Game({map_context: map_canvas.getContext('2d'),
sprite_context: sprite_canvas.getContext('2d'), scale: scale,
screenBounds: {top: -4, left: -4, bottom: 180, right: 260} });
// hide the "please wait" throbber
dojo.style("throbber","display","none")
// start the game loop
game.start();
// hook up the keyboard event handlers for player input
dojo.connect(window, "onkeydown", handle_keydown);
dojo.connect(window, "onkeyup", handle_keyup);
} // end of init_game()
/* handle user input/controls */
var isIE = navigator.appName.toLowerCase().indexOf("explorer") > -1;
handle_keydown = function(e){
var ev = isIE?event:e;
game.keyDown(ev.keyCode);
}
handle_keyup = function(e){
var ev = isIE?event:e;
game.keyUp(ev.keyCode);
}
/*
* Konami-JS
* http://snaptortoise.com/konami-js
* Copyright (c) 2009 George Mandis (georgemandis.com)
* Version: 1.0 (04/27/2009)
* Licensed under the Artistic License/GPL
* http://dev.perl.org/licenses/
* Tested in: Safari 4, Firefox 3, IE7
*/
var konami = {
input:"",
clear: setTimeout('konami.clear_input()',2000),
clear_input: function() {
konami.input="";
clearTimeout(konami.clear);
},
check_input: function(keyCode) {
if (keyCode == 13) {keyCode = 221;} // ENTER key can be understood as an alternate START button
this.input += keyCode; //e ? e.keyCode : event.keyCode;
//if (console && console.log) { console.log("Konami input:", this.input); }
if (konami.input == "38384040373937399088221") {
konami.code();
clearTimeout(konami.clear);
}
clearTimeout(konami.clear);
konami.clear = setTimeout('konami.clear_input()',2000);
},
code: function() {
var msg = dojo.byId("user_msg");
msg.innerText = "Cheaters never prosper!";
dojo.style("user_msg", "display", "inline");
game.cheat();
}
}
</script>
</head>
<body class="origSize">
<canvas id="map" width="256" height="240">No canvas found, or canvas 2d context cannot be retrieved.</canvas>
<canvas id="sprites" width="256" height="240"></canvas>
<div id="throbber"><img src="loc/res/wait.gif" /><br/>Loading resources...</div>
<div class="controls">
<img id="pad" src="loc/res/nespad.png" alt="" usemap="#padmap" />
<map name="padmap">
<!-- up -->
<area shape="rect" coords="34,43,59,65" onmousedown="game.keyDown(38);" onmouseup="game.keyUp(38);" title="(up arrow)"/>
<!-- left -->
<area shape="rect" coords="20,60,41,83" onmousedown="game.keyDown(37);" onmouseup="game.keyUp(37);" onmouseout="game.keyUp(37);" title="(left arrow)"/>
<!-- right -->
<area shape="rect" coords="55,60,76,83" onmousedown="game.keyDown(39);" onmouseup="game.keyUp(39);" onmouseout="game.keyUp(39);" title="(right arrow)"/>
<!-- down -->
<area shape="rect" coords="34,81,59,103" onmousedown="game.keyDown(40);" onmouseup="game.keyUp(40);" onmouseout="game.keyUp(40);" title="(down arrow)"/>
<!-- select -->
<area shape="rect" coords="100,81,124,92" onmousedown="game.keyDown(219);" onmouseup="game.keyUp(219);" title="([ button)"/>
<!-- start -->
<area shape="rect" coords="137,81,161,92" onmousedown="game.keyDown(221);" onmouseup="game.keyUp(221);" title="(] button)" />
<!-- B button -->
<area shape="circle" coords="199,85,14" onmousedown="game.keyDown(90);" onmouseup="game.keyUp(90);" onmouseout="game.keyUp(90);" title="(Z button)" />
<!-- A button -->
<area shape="circle" coords="237,85,14" onmousedown="game.keyDown(88);" onmouseup="game.keyUp(88);" onmouseout="game.keyUp(88);" title="(X button)" />
</map>
<br/>
<span>Controls: arrow keys, [ ] Z X</span>
<button id="resetButton" class="nesButton" onClick="game.reset();">reset</button><br/>
<span id="user_msg" style="color:red; display:none; width:100%;">Cheaters never prosper!</span>
<!--a href="index.html">1x size</a> | <a href="index2x.html">2x size</a> | <a href="index3x.html">3x size</a-->
</div>
<!--div class="debugControls">
<div class="controlGroup">
<div id="debugTray">Debug message</div><br/>
<div id="bossBanner">BOSS MODE</div>
</div>
</div-->
<button id="cheatButton" class="nesButton" onClick="game._cheat();" style="position: absolute; bottom: 5px; right: 5px;">all items</button>
</body>
</html>