battleship/demo/public/client.js

29 lines
686 B
JavaScript
Raw Normal View History

2022-09-14 09:34:39 +00:00
const canvas = document.getElementById('canvas')
const ctx = canvas.getContext('2d')
const ColorBackgroud = '#000'
const CanvasWidth = 1000, CanvasHeight = 500
const client = { id: "", io: io() }
client.io.on('id', id => client.id = id)
canvas.width = CanvasWidth
canvas.height = CanvasHeight
ctx.fillstyle = ColorBackgroud
ctx.fillRect(0, 0, CanvasWidth, CanvasHeight)
document.addEventListener('click', event => {
console.log(event)
switch (event.key) {
case 'ArrowUp':
break
case 'ArrowDown':
break
case 'ArrowLeft':
break
case 'ArrowRight':
break
default:
break
}
})