A prototype of the Snake Game using JavaScript/ES5, HTML5 WebGL
by Ivan Enzhaev
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js"></script>
<canvas width="200" height="200" id="gameCanvas">
Your browser does not support HTML5 Canvas. Please shift to a newer browser.
</canvas>
JavaScript
// Canvas element and gl context
var canvas, gl;
canvas = document.getElementById("gameCanvas");
gl = canvas.getContext("webgl");
// Run Game Loop
setInterval(gameLoop, 200)
function gameLoop()
{
update();
draw();
}
function update()
{
}
function draw()
{
clearCanvas(0.0, 0.0, 0.0)
// drawSnake();
// drawFood();
}
function clearCanvas(r, g, b)
{
gl.clearColor(r, b, g, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
}