Code With Examples

Snake Game Design (Part -1)

inpage-crack-softwares
Written by TechPro Free

<!–Level 1–>

<canvas id=”canvas” width=”500″ height=”500″ style=”background: red”></canvas>

<script>
var cvs = document.getElementById(“canvas”);
var ctx = cvs.getcontext(“2d”);
var snakew = 10;
var snakeh = 10;

function drawsnake(x, y) {
ctx.fillstyle = “white”;
ctx.fillrect(x * snakew, y * snakeh, snakew, snakeh);
}

drawsnake(10, 2);
function demox(x, y) {
ctx.fillstyle = “black”;
ctx.fillrect(x * snakew, y * snakeh, cvs.width, snakeh);
}

for (var i = 0; i <= 50; i++) {
i++;
demox(0, i);
}

function demoy(x, y) {
ctx.fillstyle = “black”;
ctx.fillrect(x * snakew, y * snakeh, snakeh, cvs.height);
}

for (var i = 0; i <= 50; i++) {
i++;
demoy(i, 0);
}

</script>

About the author

TechPro Free

Techprofree.com is Platform which offers Free download latest project source code in java, android, php, html, c# .net, c/c++, iphone, vb, python, jsp, asp .net, all programming lanugage.

Leave a Comment