Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private float speed = 3;
- private double theta;
- private double phi;
- public void move(){
- theta = Math.toRadians(pitch);
- phi = Math.toRadians(yaw);
- if(Keyboard.isKeyDown(Keyboard.KEY_W)){
- position.x+=(speed * Math.sin(phi) * Math.cos(theta));
- position.z-=(speed * Math.cos(phi));
- position.y+=(speed * -Math.sin(theta));
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_D)){
- position.x+=speed * Math.cos(phi);
- position.z+=speed * Math.sin(phi);
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_A)){
- position.x-=speed * Math.cos(phi);
- position.z-=speed * Math.sin(phi);
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_S)){
- position.x-=(speed * Math.sin(phi) * Math.cos(theta));
- position.z+=(speed * Math.cos(phi));
- position.y-=(speed * -Math.sin(theta));
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_Q)){
- position.y-=speed;
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_E)){
- position.y+=speed;
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT)){
- yaw+=speed/2;
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)){
- yaw-=speed/2;
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_UP)){
- pitch-=speed/2;
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_DOWN)){
- pitch+=speed/2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement