text: // Enemies our player must avoid
  var Enemy = function(x, y, speed) {
      // Variables applied to each of our instances go here,
      // we've provided one for you to get started
      this.x = x;
      this.y = y;
      this.speed = speed;
  
      // The image/sprite for our enemies, this uses
      // a helper we've provided to easily load images
      this.sprite = 'images/enemy-bug.png';
  };
  
  // Update the enemy's position, required method for game
  // Parameter: dt, a time delta between ticks
  Enemy.prototype.update = function(dt) {
      // You should multiply any movement by the dt parameter
      // which will ensure the game runs at the same speed for
      // all computers.
      this.x += this.speed * dt; // need to increment
  
      // clash
      if (player.x - this.x < 60 && player.x - this.x > -30 &&
          player.y - this.y < 30 && player.y - this.y > -30) {
          resetPlayer();
      }
  
      //loop
      if (this.x > 505) {
          this.x = 0;
          this.speed = Math.floor(Math.random() * 250) + 100;
      }
  };
  
  // Draw the enemy on the screen, required method for game
  Enemy.prototype.render = function() {
      ctx.drawImage(Resources.get(this.sprite), this.x, this.y);
  };
  
  // Now write your own player class
  // This class requires an update(), render() and
  // a handleInput() method.
  var Player = function(x, y) {
      this.x = x;
      this.y = y;
      this.sprite = 'images/char-boy.png';
  };
  
  Player.prototype.update = function() {
      if (this.y >= 390) {
          this.y = 390;
      }
  
      if (this.y < -10) {
          this.y = -10;
      }
  
      if (this.x >= 400) {
          this.x = 400;
      }
  
      if (this.x <= 0) {
          this.x = 0;
      }
  
      if (this.y < 0) {
          score += 1;
          updateScore();
          resetPlayer();
      }
  };
  
  Player.prototype.render = function() {
      ctx.drawImage(Resources.get(this.sprite), this.x, this.y);
  };
  
  Player.prototype.handleInput = function(keyPress) {
      var moveX = 100;
      var moveY = 80;
      switch (keyPress) {
          case 'left':
              this.x -= moveX;
              break;
          case 'up':
              this.y -= moveY;
              break;
          case 'right':
              this.x += moveX;
              break;
          case 'down':
              this.y += moveY;
              break;
      }
  };
  
  var resetPlayer = function() {
      player.x = 200;
      player.y = 390;
  }
  
  var updateScore = function() {
      scoreDiv.innerHTML = 'Score: ' + score;
  }
  
  // Now instantiate your objects.
  // Place all enemy objects in an array called allEnemies
  // Place the player object in a variable called player
  var allEnemies = [];
  var enemyY = [60, 145, 230];
  var player = new Player(200, 390);
  var minSpeed = 100;
  var score = 0;
  var scoreDiv = document.createElement('div');
  var canvasDiv = document.getElementsByTagName('canvas')[0];
  document.body.insertBefore(scoreDiv, canvasDiv);
  updateScore();
  
  enemyY.forEach(function(y) {
      var enemy = new Enemy(0, y, Math.floor(Math.random() * 250) + minSpeed);
      allEnemies.push(enemy);
  });
  
  // This listens for key presses and sends the keys to your
  // Player.handleInput() method. You don't need to modify this.
  document.addEventListener('keyup', function(e) {
      var allowedKeys = {
          37: 'left',
          38: 'up',
          39: 'right',
          40: 'down'
      };
  
      player.handleInput(allowedKeys[e.keyCode]);
  });
  