Skip to content

Commit

Permalink
Added properties to the player to control head bob
Browse files Browse the repository at this point in the history
  • Loading branch information
Interrupt committed Dec 19, 2018
1 parent 62cb6f8 commit 5beea46
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Dungeoneer/src/com/interrupt/dungeoneer/entities/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public class Player extends Actor {

public float jumpHeight = 0.05f;
public float eyeHeight = 0.12f;
public float headBobSpeed = 0.319f;
public float headBobHeight = 0.3f;

public boolean hasAttacked;

Expand Down Expand Up @@ -524,7 +526,7 @@ else if (za < 0) {
}

// headbob
headbob = (float)Math.sin(tickcount * 0.319f) * Math.min((Math.abs(xa) + Math.abs(ya)), 0.15f) * 0.3f; //TODO: Add an option to disable bob
headbob = (float)Math.sin(tickcount * headBobSpeed) * Math.min((Math.abs(xa) + Math.abs(ya)), (headBobHeight * 0.5f)) * headBobHeight;
if(floating) headbob = 0;

// water movement
Expand Down Expand Up @@ -565,7 +567,7 @@ else if (za < 0) {
// let the player climb up out of the water
stepHeight = 0.3499f + (waterTile.floorHeight + 0.5f - z);

headbob = (float)Math.sin(tickcount / 24.0f) * 0.02f;
headbob = (float)Math.sin(tickcount / 24.0f) * (headBobHeight * 0.067f);
inwater = true;
}
else {
Expand Down

0 comments on commit 5beea46

Please sign in to comment.