Guest User

Untitled

a guest
May 27th, 2017
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. import com.nolimitscoaster.*;
  2. import nlvm.math3d.*;
  3.  
  4. public class CarAction {
  5.    
  6.     private CarHandler handler;
  7.     private float startTime;
  8.     private float totalTime;
  9.     private float endTime;
  10.     private int direction;
  11.    
  12.     //Animation directions
  13.     private final int LEFT = 0;
  14.     private final int RIGHT = 1;
  15.     private final int FRONT = 2;
  16.     private final int BACK = 3;
  17.    
  18.     private Vector3f objectRotation;
  19.    
  20.     public CarAction(CarHandler handler, float startTime, float totalTime, int direction) {
  21.         this.handler = handler;
  22.         this.startTime = startTime;
  23.         this.totalTime = totalTime;
  24.         this.endTime = startTime + totalTime;
  25.         this.direction = direction;
  26.        
  27.         objectRotation = new Vector3f();
  28.     }
  29.    
  30.     public CarAction(CarHandler handler, double startTime, float totalTime, int direction) {
  31.         this(handler, (float) startTime, totalTime, direction);
  32.     }
  33.    
  34.     public void process(float tick) {
  35.         double currentTime = handler.getSim().getCurAbsSimulationTimeSec();
  36.         if (currentTime >= endTime) {
  37.             return;
  38.         }
  39.        
  40.         switch(direction) {
  41.             case LEFT:
  42.                 handler.changeZRotation(true, .005f);
  43.                 break;
  44.            
  45.             case RIGHT:
  46.                 handler.changeZRotation(false, .005f);
  47.                 break;
  48.            
  49.             case FRONT:
  50.                 handler.changeXRotation(false, .005f);
  51.                 break;
  52.            
  53.             case BACK:
  54.                 handler.changeXRotation(true, .005f);
  55.                 break;
  56.            
  57.             default:
  58.                 System.err.println("Wrong movement direction!");
  59.                 break;
  60.         }
  61.     }
  62. }
Add Comment
Please, Sign In to add comment