perfettiful
3/28/2018 - 11:54 PM

Captain Planet Keyboard move controls

    // Keyboard move controls
    $(document).keyup(function(e) {
      switch (e.which) {

      // Move Buttons (Keyboard Down)
      case 40:
        captainPlanet.animate({ top: "+=200px" }, "normal");
        break;

        // Move Buttons (Keyboard Right)
      case 39:
        captainPlanet.animate({ left: "+=200px" }, "normal");
        break;

        // Move Buttons (Keyboard Up)
      case 38:
        captainPlanet.animate({ top: "-=200px" }, "normal");
        break;

        // Move Buttons (Keyboard Left)
      case 37:
        captainPlanet.animate({ left: "-=200px" }, "normal");
        break;

      default:
        break;
      }
    });