title: How to add object collision to this wall?
body: <p>I made this code: <a href="https://code.sololearn.com/W3i7v2LuHhoB" rel="nofollow noreferrer">https://code.sololearn.com/W3i7v2LuHhoB</a> but I can't get the object collision to work. I searched on a lot of forums, YouTube, etc and still can't find it.</p>
  
  <pre><code>var rightArrow = 0;
  
  function leftArrowPressed() {
    var element = document.getElementById("image1");
    element.style.left = parseInt(element.style.left) - 5 + 'px';
  }
  
  function rightArrowPressed() {
    if (rightArrow === 0)
      var element = document.getElementById("image1");
    element.style.left = parseInt(element.style.left) + 5 + 'px';
  }
  
  function upArrowPressed() {
    var element = document.getElementById("image1");
    element.style.top = parseInt(element.style.top) - 5 + 'px';
  }
  
  function downArrowPressed() {
    var element = document.getElementById("image1");
    element.style.top = parseInt(element.style.top) + 5 + 'px';
  }
  
  function moveSelection(evt) {
    switch (evt.keyCode) {
      case 37:
        leftArrowPressed();
        break;
      case 39:
        rightArrowPressed();
        break;
      case 38:
        upArrowPressed();
        break;
      case 40:
        downArrowPressed();
        break;
    }
  };
  </code></pre>
  
  <p>I don't get any errors.</p>