SHARE
TWEET

TestCamera.java

PandaMoniumHUN Dec 23rd, 2013 47 Never
  1. package com.pandadev.testgame;
  2.  
  3. import org.lwjgl.input.Keyboard;
  4. import org.lwjgl.util.vector.Vector3f;
  5.  
  6. import com.pandadev.eyecandy.graphics.Camera;
  7.  
  8. public class TestCamera extends Camera{
  9.         private final float movement_speed = 0.1f;
  10.        
  11.         @Override
  12.         public void update(float delta) {
  13.                 if(Keyboard.isKeyDown(Keyboard.KEY_W)){
  14.                         Vector3f forward = getForward();
  15.                         getPosition().translate(forward.x*movement_speed*delta, forward.y*movement_speed*delta, forward.z*movement_speed*delta);
  16.                 }
  17.                 if(Keyboard.isKeyDown(Keyboard.KEY_S)){
  18.                         Vector3f backward = getBackward();
  19.                         getPosition().translate(backward.x*movement_speed*delta, backward.y*movement_speed*delta, backward.z*movement_speed*delta);
  20.                 }
  21.                 if(Keyboard.isKeyDown(Keyboard.KEY_A)){
  22.                         Vector3f left = getLeft();
  23.                         getPosition().translate(left.x*movement_speed*delta, left.y*movement_speed*delta, left.z*movement_speed*delta);
  24.                 }
  25.                 if(Keyboard.isKeyDown(Keyboard.KEY_D)){
  26.                         Vector3f right = getRight();
  27.                         getPosition().translate(right.x*movement_speed*delta, right.y*movement_speed*delta, right.z*movement_speed*delta);
  28.                 }
  29.         }
  30.        
  31. }
RAW Paste Data
Top