-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.js
74 lines (66 loc) · 2.68 KB
/
setup.js
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
/////////// requestAnimationFrame shim
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame =
window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame)
window.requestAnimationFrame = function(callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
if (!window.cancelAnimationFrame)
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}());
/////////// performance.now() shim
window.performance = window.performance || {};
performance.now = (function() {
return performance.now ||
performance.mozNow ||
performance.msNow ||
performance.oNow ||
performance.webkitNow ||
function() { return new Date().getTime(); };
})();
window.addEventListener('dragstart', function(){return false;}, true);
CanvasTag = document.getElementById("draw_canvas");
CanvasTag.focus();
Canvas = CanvasTag.getContext("2d");
physExecuteMs = 7;
tempFlag = false;
Preloader.ready(function(){
console.log("Preloader finished: Beginning game...");
begin_game();
});
Preloader.addImage([
"images/grass_tileset/grass_single.png",
"images/grass_tileset/grass_bottom_single.png",
"images/grass_tileset/grass_right_single.png",
"images/grass_tileset/grass_bottom_right.png",
"images/grass_tileset/grass_left_single.png",
"images/grass_tileset/grass_bottom_left.png",
"images/grass_tileset/grass_middle_single_horizontal.png",
"images/grass_tileset/grass_bottom_middle.png",
"images/grass_tileset/grass_top_single.png",
"images/grass_tileset/grass_middle_single_vertical.png",
"images/grass_tileset/grass_top_right.png",
"images/grass_tileset/grass_middle_right.png",
"images/grass_tileset/grass_top_left.png",
"images/grass_tileset/grass_middle_left.png",
"images/grass_tileset/grass_top_middle.png",
"images/grass_tileset/ground_tile.png",
"images/rock_tileset/platform_only.png",
"images/rock_tileset/platform_underneath.png",
"images/rock_tileset/platform.png",
"images/spike_tileset/spike_pit.png",
"images/spike_tileset/spike_lower.png"
]);