-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
30 lines (28 loc) · 972 Bytes
/
main.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
$(document).ready(function () {
init();
});
function init() {
ctx = document.getElementById('mainC').getContext('2d');
backCtx = document.getElementById('backC').getContext('2d');
topCtx = document.getElementById('topC').getContext('2d');
renderData.loadImages();
changeScreen(startScreen, handleStartScreen);
}
function changeScreen(newUpdate, newEvent) {
ctx.setTransform(1, 0, 0, 1, 0, 0);
backCtx.setTransform(1, 0, 0, 1, 0, 0);
topCtx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, WIDTH, HEIGHT);
backCtx.clearRect(0, 0, WIDTH, HEIGHT);
topCtx.clearRect(0, 0, WIDTH, HEIGHT);
dirty = true;
if (loopID > 0) {
clearInterval(loopID);
window.removeEventListener('keydown', eventFun, true);
window.removeEventListener('keyup', eventFun, true);
}
loopID = setInterval(newUpdate, 1000/FPS);
eventFun = newEvent;
window.addEventListener('keydown', eventFun, true);
window.addEventListener('keyup', eventFun, true);
}