I am writing a game and for example I took the HTML5 Games Guide without tears
I try to keep the structure as it is, and for this I rewrote part of my old code. After that, it stopped working and gives an error
SyntaxError: expected expression, got ';' [Learn More] snake.html: 24: 22a
How to fix ?
<!doctype html> <html> <head> <title> Snake </title> <meta charset='utf-8' /> </head> <body> <canvas id='canvas' width="800" height="600" style="border: 1px solid #000000;"></canvas> <style>#canvas { background-color: rgba(158, 167, 184, 0.2); }</style> <script type = "text/javascript"> var canvas = document.getElementById("canvas"); ctx = canvas.getContext('2d'); var dx = 0; var dy = 0; var FPS = 30; setInterval(function () { function update(); function draw(); } 1000/FPS); function update(){ dx++; window.requestAnimationFrame(draw); } function draw(){ ctx.clearRect(0, 0, 800, 600); ctx.fillStyle = "green"; ctx.fillRect(dx, dy, 25, 25); } </script> </body> </html>