Code With Examples

Snake Game Design (Part -1)

inpage-crack-softwares
Written by Zaheer Alam

<!–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

Zaheer Alam

Zaheer Alam is an Software Engineer Graduated From Well Versed institute of Aisa, Comsats University.He is inclined toward helping People improve their Programming Skill to the Next Level.He also works work as social media content creator on various pages and groups with the huge fan following.

Leave a Comment