Retro games feel incredible on the canvas API. This snake array pushes new head coordinates and pops the tail unless it eats the apple.

The Movement Update

JAVASCRIPT CODE
let snake = [{x: 10, y: 10}];
let velocity = {x: 1, y: 0};

function gameLoop() {
  const head = { x: snake[0].x + velocity.x, y: snake[0].y + velocity.y };
  snake.unshift(head);
  
  if (head.x === food.x && head.y === food.y) {
    score++;
    placeFood();
  } else {
    snake.pop(); // Remove tail if no food eaten
  }
}

See the Live Demo to experience the glowing neon aesthetics!