Skip to content

Commit

Permalink
getJumpPos now handles the case where boundary has shifted casugin de…
Browse files Browse the repository at this point in the history
…mon to be out of bounds
  • Loading branch information
gregchan550 committed Sep 20, 2023
1 parent 9191bd2 commit be35ccc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void create() {

// Set up infrastructure for end game tracking
player = spawnPlayer();
player.getEvents().addListener("spawnWave", this::spawnWave);
//player.getEvents().addListener("spawnWave", this::spawnWave);

//playMusic();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void run() {
xLeftBoundary -= 2;
xRightBoundary -= 2;
}
}, MOVE_FORWARD_DELAY);
}, MOVE_FORWARD_DELAY * i);
}
}

Expand Down Expand Up @@ -218,6 +218,7 @@ private Array<Entity> getNearbyHumans() {
}

private void jump(Vector2 finalPos) {
System.out.println(finalPos);
changeState(DemonState.SMASH);
isJumping = true;

Expand All @@ -230,6 +231,12 @@ private void jump(Vector2 finalPos) {
}

private Vector2 getJumpPos() {
// check if boundary has shifted causing demon to be out of bounds
if (currentPos.x > xRightBoundary) {
jumpPos = new Vector2(currentPos.x - JUMP_DISTANCE, currentPos.y); //jump back into boundary
return jumpPos;
}

float randomAngle = MathUtils.random(0, 2 * MathUtils.PI);
float x = JUMP_DISTANCE * MathUtils.cos(randomAngle);
float y = JUMP_DISTANCE * MathUtils.sin(randomAngle);
Expand Down

0 comments on commit be35ccc

Please sign in to comment.