forked from facerix/Canvassa
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
165 lines (146 loc) · 6.25 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
<?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.3/dojo/dojo.js"></script>
<!--[if IE]>
<script type="text/javascript" src="http://pipes.yahoo.com/js/excanvas.js"></script>
<![endif]-->
<style type="text/css">
div.controls {
top: 20px;
left: 300px;
}
div.debugControls {
top: 100px;
left: 300px;
}
#throbber {
position: absolute;
left: 40px;
top: 120px;
text-align: center;
}
area {
cursor: pointer;
}
img#pad {
border-style: none;
}
.nesButton {
background-color: #BBB;
border: 2px outset black;
color: #900;
cursor: pointer;
float: right;
font: normal small-caps normal 12px 'Arial Black',Gadget,sans-serif;
padding: 6px 3px 0 18px;
}
</style>
<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 (map_canvas.getContext){
dojo.require("loc.Preloader");
dojo.addOnLoad(preload);
} else {
dojo.style("throbber", "width", "220px")
dojo.byId("throbber").innerHTML = "No canvas found, or canvas 2d context cannot be retrieved.";
}
}); // end of init_loader()
function preload() {
window.loader = new loc.Preloader({
images: {
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._quest1", "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);
}
</script>
</head>
<body class="origSize">
<canvas id="map" width="256" height="240"></canvas>
<canvas id="sprites" width="256" height="240"></canvas>
<div id="throbber" style="display: none;"><img src="loc/res/wait.gif" /><br/>Loading resources...</div>
<div class="controls">
<img id="pad" src="../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);"/>
<!-- left -->
<area shape="rect" coords="20,60,41,83" onmousedown="game.keyDown(37);" onmouseup="game.keyUp(37);" onmouseout="game.keyUp(37);" />
<!-- right -->
<area shape="rect" coords="55,60,76,83" onmousedown="game.keyDown(39);" onmouseup="game.keyUp(39);" onmouseout="game.keyUp(39);" />
<!-- down -->
<area shape="rect" coords="34,81,59,103" onmousedown="game.keyDown(40);" onmouseup="game.keyUp(40);" onmouseout="game.keyUp(40);" />
<!-- select -->
<area shape="rect" coords="100,81,124,92" onmousedown="game.keyDown(219);" onmouseup="game.keyUp(219);" />
<!-- start -->
<area shape="rect" coords="137,81,161,92" onmousedown="game.keyDown(221);" onmouseup="game.keyUp(221);" />
<!-- B button -->
<area shape="circle" coords="199,85,14" onmousedown="game.keyDown(90);" onmouseup="game.keyUp(90);" onmouseout="game.keyUp(90);" />
<!-- A button -->
<area shape="circle" coords="237,85,14" onmousedown="game.keyDown(88);" onmouseup="game.keyUp(88);" onmouseout="game.keyUp(88);" />
</map>
<br/>
<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>