2d game with canvas

HTML

<canvas id="canvas"></canvas>

CSS

* {
  padding: 0;
  margin: 0;
  overflow: hidden;
}

body {
  height: 600px;
}

JavaScript

d //задаем начальные переменные
var canvas, context, image, bg,
  keyBoard = {}, globalX = 0, gameOver = false,
  startTime = new Date().getTime(), finishTime = 0;
var level = [ 
  [-1000, 100], [-500, 0], [210, 10], 
  [250, -100], [300, -100], [350, 10], 
  [1500, 40], [1600, -140], [1700, 40], 
  [3700, 200], [4800, 80], [5500, 150], 
  [5600, 90], [5700, -500], [6000, 40],
  [6800, 250], [7400, 150], [7550, 150], 
  [7600, -160], [7700, -160], [7950, 60],
  [8700, 260], [10700, 100], [13000, 300],
];

/*window.addEventListener('load', onLoad, true);*/
(function onLoad() {
  canvas = document.getElementById("canvas");
  context = canvas.getContext("2d");
  
  canvas.onclick = function () {
    if (gameOver) {
      player.x = 0;
      player.y = 0;
      player.speed = 0;
      globalX = 0;
      gameOver = false;
      startTime = new Date().getTime();
    }
  };

  //Создаем и загружаем изображения
  bg = new Image();
  bg.src = "http://gohtml.ru/images/news/104-lovely-mountain.jpg";

  image = new Image();
  image.src = "http://gohtml.ru/images/news/109-person.png";
  image.onload = function () {
    player = new gameObject(context, image);
  };

  document.onkeydown = function (e) {
    keyBoard[e.keyCode] = true;

    switch (e.keyCode) {
      case 87:
      case 38:
      case 32:
      case 65:
      case 37:
      case 68:
      case 39:
        return false;
      default:
        break;
    }
  }
  document.onkeyup = function (e) {
    keyBoard[e.keyCode] = false;
  }

  //функция перерисовки холста
  function repaint(X, Y) {
  	canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    
    context.strokeStyle = "#ffaa00";
    context.lineWidth = 60;
    context.lineCap = "round";
    context.fillStyle = "#fff";
    context.textAlign = "center";
    context.textBaseline = "middle";
    
    if ((keyBoard[87] || keyBoard[38] || keyBoard[32]) && player.isGrounded()) {
      player.speedY += 13;
    }
    if ((keyBoard[65] ||...