Advertisement
DJSandmannTV

controls.java

Dec 7th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. public class controls extends animation {
  2.    
  3.     boolean goUp, goDown, goLeft, goRight;
  4.    
  5.     public void check() {
  6.        
  7.         keyPressed();
  8.         keyReleased();
  9.        
  10.     }
  11.    
  12.     public void keyPressed() {
  13.         setMove(keyCode, true);
  14.     }
  15.    
  16.     public void keyReleased() {
  17.         setMove(keyCode, false);
  18.     }
  19.    
  20.     boolean setMove(int key, boolean b) {
  21.        
  22.         switch (key) {
  23.        
  24.         case UP:
  25.            
  26.             return goUp = b;
  27.                
  28.         case DOWN:
  29.            
  30.             return goDown = b;
  31.            
  32.         case LEFT:
  33.            
  34.             return goLeft = b;
  35.            
  36.         case RIGHT:
  37.            
  38.             return goRight = b;
  39.            
  40.         default:
  41.            
  42.             return b;
  43.            
  44.         }
  45.  
  46.     }
  47.        
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement