Let's make a game with SVG!

1

In this presentation we are going to develop a small snake game with SVG and JavaScript.

Here we go!

Let's start with set game frame with next set of code:

        var svgns = "http://www.w3.org/2000/svg",
            svg = document.createElementNS(svgns, "svg"),
            rectSize = 31,
            matrixSize = 15,
            matrixLimit = matrixSize - 1;
            speedMs = 250;
        svg.setAttributeNS(null, 'width', rectSize * matrixSize);
        svg.setAttributeNS(null, 'height', rectSize * matrixSize);
        svg.setAttributeNS(null, 'style', 'border: ' + rectSize + 'px solid #ccc;');
        document.getElementById("#ElementId").appendChild(svg);