-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
43 lines (33 loc) · 824 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
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Imports } from "./lib/import.js";
// import kd, { tick } from "./lib/utills/KeyManager.js";
var game = new Imports(this)
var fps=0
requestAnimationFrame(stick)
function stick(){
// document.getElementById("debug").innerHTML = `A not pressed ${game.player.x}`;
if(kd.RIGHT.isDown()){
game.camera.velR = -10
}
if(kd.LEFT.isDown()){
game.camera.velR = 10
}
if(kd.Q.isDown()){
game.camera.ImpactCameraShake()
}
game.camera.tick()
game.player.tick()
game.display.tick()
kd.tick()
game.debug.tick()
FPSCalc()
requestAnimationFrame(stick)
}
async function FPSCalc(){
fps++
await sleep(1000)
fps--
game.debug.fpsCount = fps
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}