Problem with the code
Game Development with JavaScript course. Please tell me why the code is not working? window.onload = function(){ var canvas = document.getElementById("canvas"); var context = canvas.getContext("2d"); var x = 300; var y = 350; var t = Date.now; var speed = 25; let count = 0; document.onmousedown = function(){ count += 1; y -= 25; speed = 25; } document.onkeydown = function(){ count += 1; y -= 25; speed = 25; } document.ontouchstart = function(){ count += 1; y -= 25; speed = 25; } function draw(){ var timePassed = (Date.now() - t) / 1000; t = Date.now(); context.clearRect(0, 0, 600, 400); context.font = "25px Arial"; context.fillStyle = "#ffffff"; context.fillText("Count: " + count, 20, 30); context.beginPath(); context.arc(x, y, 50, 0, 2 * Math.PI); context.fillStyle = "red"; context.fill(); if(y <= 350){ speed += 50 * timePassed; y += speed * timePassed; //when I add this line the circle disappears and the code doesn't work properly } if(y > 350){ count = 0 } window.requestAnimationFrame(draw); } draw(); }