Advertisement
Guest User

How I'd probably do controls

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