var puppy = {
  x: 550,
  y: 490,
  alive: true,
  won: false,
  canMove: true,
};

var bone1 = {
  x: 560,
  y: 80,
  alive: true,
};

var bone2 = {
  x: 560,
  y: 200,
  alive: true,
};

var bacon = {
  x: 560,
  y: 320,
  alive: true,
};

document.getElementById("up").onclick = function() {move(38);};
document.getElementById("down").onclick = function() {move(40);};
document.getElementById("right").onclick = function() {move(39);};
document.getElementById("left").onclick = function() {move(37);};

var puppyImg = document.getElementById("puppy");
var boneImg1 = document.getElementById("bone1");
var boneImg2 = document.getElementById("bone2");
var baconImg = document.getElementById("bacon");

var boneCount = 3;

function move(direction){
  if (puppy.canMove){
    console.log('moving');
    food_move(bone1, boneImg1);
    food_move(bone2, boneImg2);
    food_move(bacon, baconImg);
  if (puppy.canMove){
    console.log('moving');
    if (direction.keyCode === 38 || direction === 38){ // move up
      if (puppy.y > 50){
        puppy.y = (puppy.y - 10);
        puppyImg.style.top = (puppy.y + "px");
      }
    }else if (direction.keyCode === 40 || direction === 40){ // move down
      if (puppy.y < 490){
        puppy.y = (puppy.y + 10);
        puppyImg.style.top = (puppy.y + "px");
      }
    }else if (direction.keyCode === 39 || direction == 39){ // move right
      if (puppy.x < 1200){
        puppy.x = (puppy.x + 10);
        puppyImg.style.left = (puppy.x + "px");
      }

    }else if (direction.keyCode === 37 || direction == 37){ // move left
      if (puppy.x > 550){
        puppy.x = (puppy.x - 10);
        puppyImg.style.left = (puppy.x + "px");
      }
    }
  }
}
}

function food_move(food, foodImg){
  var random = Math.floor((Math.random() * 4) + 1);
  if (random === 1){
    if (food.y > 50){
      food.y = (food.y - 10);
      foodImg.style.top = (food.y + "px");
    }
  }else if (random === 2){
    if (food.y < 490){
      food.y = (food.y + 10);
      foodImg.style.top = (food.y + "px");
    }
  }else if (random === 3){
    if (food.x < 1200){
      food.x = (food.x + 10);
      foodImg.style.left = (food.x + "px");
    }
  }else{
    if (food.x > 550){
      food.x = (food.x - 10);
      foodImg.style.left = (food.x + "px");
    }
 }
}

document.onkeydown = move;
@@ -768,35 +768,8 @@
 e)%7B%0A
-    console.log('moving');%0A
     
@@ -886,35 +886,8 @@
 e)%7B%0A
-    console.log('moving');%0A
     
@@ -1798,25 +1798,25 @@
 = (food.y - 
-1
+2
 0);%0A      fo
@@ -1927,25 +1927,25 @@
 = (food.y + 
-1
+2
 0);%0A      fo
@@ -2057,25 +2057,25 @@
 = (food.x + 
-1
+2
 0);%0A      fo
@@ -2169,25 +2169,25 @@
 = (food.x - 
-1
+2
 0);%0A      fo

Change position of all the food