- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
Latest commit
22 lines (19 loc) · 614 Bytes
/
Copy pathscript.js
File metadata and controls
22 lines (19 loc) · 614 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
window.addEventListener('load',function(){
// canvas setup
constcanvas=this.document.getElementById('canvas1');
constctx=canvas.getContext('2d');
canvas.width=1500;
canvas.height=500;
constgame=newGame(canvas.width,canvas.height);
letlastTime=0;
// animation loop
functionanimate(timeStamp){
constdeltaTime=timeStamp-lastTime;
lastTime=timeStamp;
ctx.clearRect(0,0,canvas.width,canvas.height);
game.draw(ctx);
game.update(deltaTime);
requestAnimationFrame(animate)
}
animate(0);
})