Advertisement
Sirius_Crack

Untitled

May 7th, 2021
912
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. public void update() {
  2.     // speed calculation
  3.     if (this.speedHorizontalTarget != this.speedHorizontal) {
  4.         if (this.speedHorizontalTarget > this.speedHorizontal) {
  5.             this.speedHorizontal += this.accelerationHorizontal;
  6.             if (this.speedHorizontal > speedHorizontalTarget)
  7.                 this.speedHorizontal = speedHorizontalTarget;
  8.         } else {
  9.             this.speedHorizontal -= this.accelerationHorizontal;
  10.             if (this.speedHorizontal < this.speedHorizontalTarget)
  11.                 this.speedHorizontal = speedHorizontalTarget;
  12.         }
  13.     }
  14.  
  15.     // direction calculation
  16.     if (this.headingTargetDirection = true) {
  17.         if (this.heading < this.headingTarget) {
  18.             this.heading += this.turnRate;
  19.             this.headingDirection = true;
  20.         }
  21.     } else {
  22.         if (this.heading > (this.headingTarget)) {
  23.             this.heading -= this.turnRate;
  24.             this.headingDirection = false;
  25.         }
  26.     }
  27.  
  28.     // position calculation
  29.     this.x += Math.cos(Math.toRadians(this.heading)) * this.speedHorizontal; // x pos + (heading * speed)
  30.     this.y += Math.sin(Math.toRadians(this.heading)) * this.speedHorizontal; // y pos + (heading * speed)
  31.     this.z += speedVertical; // current z + speed of vertical ascent
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement