[Solved] Animate animals running accross the screen in Javascript [closed]


You can for example use an already animated looped gif of an animal walking. Then you can just change the position of the gif with JS.

var elem = document.getElementById("animal");
      var pos = 0;
      var id = setInterval(frame, 75);
      function frame() {
          if (pos >= 100) {
              pos = -10;
          } else {
              pos=pos+0.25;
              elem.style.left = pos + '%';
          }
      }

solved Animate animals running accross the screen in Javascript [closed]