| 1 | window.onload = function() |
| 2 | { |
| 3 | console.log("Loading Everything"); |
| 4 | GameWindow.init(0, 0, window.innerWidth - 2, window.innerHeight - 2); |
| 5 | GameWindow.fullscreen = true; |
| 6 | |
| 7 | GameInput.g_init(); |
| 8 | |
| 9 | Canvas.canvas.requestPointerLock = Canvas.canvas.requestPointerLock || |
| 10 | element.mozRequestPointerLock || |
| 11 | element.webkitRequestPointerLock; |
| 12 | // Ask the browser to lock the pointer |
| 13 | |
| 14 | Canvas.canvas.onclick = function() { |
| 15 | Canvas.canvas.requestPointerLock(); |
| 16 | } |
| 17 | |
| 18 | World.loadLevel(0); |
| 19 | |
| 20 | setInterval(function() |
| 21 | { |
| 22 | var stepTime = Date.now(); |
| 23 | var stepTimeCurr = (stepTime - stepPrevious) * 0.001; |
| 24 | |
| 25 | if(isNaN(stepTimeCurr)) |
| 26 | stepTimeCurr = 0; |
| 27 | |
| 28 | GameInput.g_updateKeys(); |
| 29 | Player.update(stepTimeCurr); |
| 30 | |
| 31 | GameWindow.redraw(); |
| 32 | |
| 33 | this.stepPrevious = stepTime; |
| 34 | }, 20); |
| 35 | } |
| 36 | |
| 37 | var stepPrevious = 0; |