Advertisement
Guest User

How I'd do controls

a guest
Aug 30th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Control = (function () {
  2.     function Control() {}
  3.     Control.prototype.keyUp = function (key) {
  4.         switch (key) {
  5.             case 39:
  6.                 Control.moveLeft = false;
  7.                 break;
  8.             case 38:
  9.                 Control.moveForward = false;
  10.                 break;
  11.             case 37:
  12.                 Control.moveRight = false;
  13.                 break;
  14.             case 40:
  15.                 Control.moveBackward = false;
  16.                 break;
  17.         }
  18.     };
  19.  
  20.     Control.prototype.keyDown = function (key) {
  21.         switch (key) {
  22.             case 39:
  23.                 Control.moveLeft = true;
  24.                 break;
  25.             case 38:
  26.                 Control.moveForward = true;
  27.                 break;
  28.             case 37:
  29.                 Control.moveRight = true;
  30.                 break;
  31.             case 40:
  32.                 Control.moveBackward = true;
  33.                 break;
  34.         }
  35.     };
  36.     Control.moveForward = false;
  37.     Control.moveBackward = false;
  38.     Control.moveLeft = false;
  39.     Control.moveRight = false;
  40.     return Control;
  41. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement