Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. private float speed = 3;
  2. private double theta;
  3. private double phi;
  4.  
  5. public void move(){
  6.         theta = Math.toRadians(pitch);
  7.         phi = Math.toRadians(yaw);
  8.         if(Keyboard.isKeyDown(Keyboard.KEY_W)){
  9.             position.x+=(speed * Math.sin(phi) * Math.cos(theta));
  10.             position.z-=(speed * Math.cos(phi));
  11.             position.y+=(speed * -Math.sin(theta));
  12.         }
  13.         if(Keyboard.isKeyDown(Keyboard.KEY_D)){
  14.             position.x+=speed * Math.cos(phi);
  15.             position.z+=speed * Math.sin(phi);
  16.         }
  17.         if(Keyboard.isKeyDown(Keyboard.KEY_A)){
  18.             position.x-=speed * Math.cos(phi);
  19.             position.z-=speed * Math.sin(phi);
  20.         }
  21.         if(Keyboard.isKeyDown(Keyboard.KEY_S)){
  22.             position.x-=(speed * Math.sin(phi) * Math.cos(theta));
  23.             position.z+=(speed * Math.cos(phi));
  24.             position.y-=(speed * -Math.sin(theta));
  25.         }
  26.        
  27.         if(Keyboard.isKeyDown(Keyboard.KEY_Q)){
  28.             position.y-=speed;
  29.         }
  30.        
  31.         if(Keyboard.isKeyDown(Keyboard.KEY_E)){
  32.             position.y+=speed;
  33.         }
  34.         if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT)){
  35.             yaw+=speed/2;
  36.         }
  37.         if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)){
  38.             yaw-=speed/2;
  39.         }
  40.        
  41.         if(Keyboard.isKeyDown(Keyboard.KEY_UP)){
  42.             pitch-=speed/2;
  43.         }
  44.         if(Keyboard.isKeyDown(Keyboard.KEY_DOWN)){
  45.             pitch+=speed/2;
  46.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement