|
let game = setInterval(initGame, 100); |
use window.requestAnimationFrame instead of setInterval.
if (snake[0].x > 15 * box) snake[0].x = 0;
don't use magic numbers like 15. Explain value with constants.
let game = setInterval(initGame, 100);
let box = 32;
Bad naming by you. box? Maybe, you mean box size? "initGame" you call this method every 100 milisecond, its game loop.
let box = 32;
If it is constant, use const instead let.
Not bad, in total.
SnakeGameJS/script.js
Line 97 in 04cef14
use window.requestAnimationFrame instead of setInterval.
if (snake[0].x > 15 * box) snake[0].x = 0;
don't use magic numbers like 15. Explain value with constants.
let game = setInterval(initGame, 100);
let box = 32;
Bad naming by you. box? Maybe, you mean box size? "initGame" you call this method every 100 milisecond, its game loop.
let box = 32;
If it is constant, use const instead let.
Not bad, in total.