forked from dannz510/Tank_Game_V2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
25 lines (20 loc) · 705 Bytes
/
main.js
File metadata and controls
25 lines (20 loc) · 705 Bytes
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
import Game from './game.js'
window.addEventListener('load', function () {
const loading = document.getElementById('loading-container')
loading.style.display = 'none'
const canvas = document.getElementById('container')
canvas.style.display = 'block'
const ctx = canvas.getContext('2d')
canvas.width = 1280
canvas.height = 1280
const game = new Game(canvas.width, canvas.height)
let lastTime = 0
const animate = (timeStamp) => {
const deltaTime = timeStamp - lastTime
lastTime = timeStamp
ctx.clearRect(0, 0, canvas.width, canvas.height)
game.render(deltaTime, ctx)
requestAnimationFrame(animate)
}
animate(0)
})