let car;
let canvas, ctx;

window.onload = () => {
  map = initMap();

  canvas = document.getElementById("game");
  ctx = canvas.getContext("2d");

  resizeCanvas();
  window.addEventListener("resize", resizeCanvas);

  car = new Car(173.284, -41.270);

  map.on("render", gameLoop);
};

function resizeCanvas() {
  canvas.width = window.innerWidth;
  canvas.height = window.innerHeight;
}

function gameLoop() {
  car.update();

  ctx.clearRect(0, 0, canvas.width, canvas.height);
  car.draw(ctx, map);
}