Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void update() {
- // speed calculation
- if (this.speedHorizontalTarget != this.speedHorizontal) {
- if (this.speedHorizontalTarget > this.speedHorizontal) {
- this.speedHorizontal += this.accelerationHorizontal;
- if (this.speedHorizontal > speedHorizontalTarget)
- this.speedHorizontal = speedHorizontalTarget;
- } else {
- this.speedHorizontal -= this.accelerationHorizontal;
- if (this.speedHorizontal < this.speedHorizontalTarget)
- this.speedHorizontal = speedHorizontalTarget;
- }
- }
- // direction calculation
- if (this.headingTargetDirection = true) {
- if (this.heading < this.headingTarget) {
- this.heading += this.turnRate;
- this.headingDirection = true;
- }
- } else {
- if (this.heading > (this.headingTarget)) {
- this.heading -= this.turnRate;
- this.headingDirection = false;
- }
- }
- // position calculation
- this.x += Math.cos(Math.toRadians(this.heading)) * this.speedHorizontal; // x pos + (heading * speed)
- this.y += Math.sin(Math.toRadians(this.heading)) * this.speedHorizontal; // y pos + (heading * speed)
- this.z += speedVertical; // current z + speed of vertical ascent
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement