I am trying a tutorial from YouTube, and when I use the following snippet, it creates a dot/pixel in the canvas. I can recreate the function multiple times with different values to create a line, but is it possible to create a straight line using the following code?
Apologies for simple question, I'm pretty new in using canvas. Thanks
let tileCount = 20; //total tiles = 20. or you can say pixels body
let tileSize = canvas.width / tileCount - 2;
let appleX = 5;
let appleY = 5;
function drawApple() { //craetes the food item for snake to collide
ctx.fillStyle = "red"; //color of apple
ctx.fillRect(appleX * tileCount, appleY * tileCount, tileSize, tileSize); //defining apple as rectangle
}