Advertisement
Guest User

Untitled

a guest
Nov 17th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- bmwM3.js.old        2012-11-17 21:20:42.438109157 +0100
  2. +++ bmwM3.js    2012-11-17 21:25:43.651911123 +0100
  3. @@ -51,9 +51,10 @@ function init_chassis(){
  4.  
  5.      this.finalRatio = 3;
  6.      this.torqueMultiplier = 10;
  7. +    this.maximumSpeed = -1; // speed in m/s. a value < 0 means there's no maximum speed
  8.      //end of engine properties
  9. -
  10. -       this.torque = engineTorque;
  11. +
  12. +    this.torque = engineTorque;
  13.  
  14.      return {mass:1500, steering:2.0, steering_ecf:60, centering: 2.6, centering_ecf:20};
  15.  }
  16. @@ -119,9 +120,9 @@ function update_frame(dt, engine, brake,
  17.      steering *= 0.6;
  18.      this.steer(-2, steering);
  19.  
  20. -
  21. -    var khm = Math.abs(this.speed()) * 3.6;
  22. -    var wheels = Math.abs(this.speed()) / (this.wheelRadius * (2 * Math.PI));
  23. +    var absSpeed = Math.abs(this.speed());
  24. +    var khm = absSpeed * 3.6;
  25. +    var wheels = absSpeed / (this.wheelRadius * (2 * Math.PI));
  26.  
  27.      var gears;
  28.      if (this.speed() >= 0) {
  29. @@ -140,7 +141,10 @@ function update_frame(dt, engine, brake,
  30.          this.gear -= 1;
  31.      }
  32.  
  33. -    var force = engine * this.torque(rpm) * this.torqueMultiplier;
  34. +    var force = 0;
  35. +    if (this.maximumSpeed < 0 || absSpeed < this.maximumSpeed) {
  36. +        force = engine * this.torque(rpm) * this.torqueMultiplier;
  37. +    }
  38.      this.wheel_force(2, force);
  39.      this.wheel_force(3, force);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement