var ctxGame = document.querySelector('#game').getContext('2d')
var ctxLight = document.querySelector('#light').getContext('2d')
var blocks = parseMap(`
----------------------------
----------------------------
----------------------------
----------------------------
----------------------------
---B-----B-------B-----B----
---B-------------B-----B----
---B-----B--BBB--BBB--BBB---
---B-----B--B-B--B-B---B----
---BBBB--B--BBB--B-B---B----
--------------B-------------
------------BBB-------------
----------------------------
----------------------------
----------------------------
----------------------------`, 16, 16)
var lights = [new Light(true, 114, 49), new Light(false, 250, 50)]
render()
function render(){
setTimeout(render, 1000/60)
ctxGame.clearRect(0, 0, ctxGame.canvas.width, ctxGame.canvas.height)
for(var block of blocks) block.draw()
ctxLight.globalCompositeOperation = 'source-over';
ctxLight.fillRect(0, 0, ctxLight.canvas.width, ctxLight.canvas.height)
for(var light of lights) light.draw()
}
function parseMap(map, gridWidth, gridHeight){