Guest User

GameDev | StackExchange - Help with Resolving Pixel Perfect

a guest
Mar 5th, 2015
51
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void update(ElapsedTime elapsedTime) {
  2.  
  3.         float dt = (float) elapsedTime.stepTime;
  4.  
  5.         // Ensure the maximum acceleration isn't exceeded
  6.         if (acceleration.lengthSquared() > maxAcceleration * maxAcceleration) {
  7.             acceleration.normalise();
  8.             acceleration.multiply(maxAcceleration);
  9.         }
  10.        
  11.         // Update the velocity using the acceleration and ensure the
  12.         // maximum velocity has not been exceeded      
  13.         velocity.add(acceleration.x * dt, acceleration.y * dt);
  14.        
  15.         if (velocity.lengthSquared() > maxVelocity * maxVelocity) {
  16.             velocity.normalise();
  17.             velocity.multiply(maxVelocity);
  18.         }
  19.  
  20.         // Update the position using the velocity
  21.         position.add(velocity.x * dt, velocity.y * dt);
  22.        
  23.         // Ensure the maximum angular acceleration isn't exceeded
  24.         if (angularAcceleration < -maxAngularAcceleration
  25.                 || angularAcceleration > maxAngularAcceleration) {
  26.             angularAcceleration = Math.signum(angularAcceleration)
  27.                     * maxAngularAcceleration;
  28.         }
  29.  
  30.         // Update the angular velocity using the angular acceleration and
  31.         // ensure the maximum angular velocity has not been exceeded       
  32.         angularVelocity += angularAcceleration * dt;
  33.  
  34.         if (angularVelocity < -maxAngularVelocity
  35.                 || angularVelocity > maxAngularVelocity) {
  36.             angularVelocity = Math.signum(angularVelocity) * maxAngularVelocity;
  37.         }
  38.  
  39.         // Update the orientation using the angular velocity
  40.         orientation += angularVelocity * dt;
  41.        
  42.  
  43.            
  44.     }
RAW Paste Data