Skip to content

Commit

Permalink
fixed indexing issue when spawning breath balls but sequencing is buggy
Browse files Browse the repository at this point in the history
  • Loading branch information
gregchan550 committed Sep 18, 2023
1 parent 3c0a196 commit 80a2c6c
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.TimeUtils;
import com.csse3200.game.ai.tasks.DefaultTask;
import com.csse3200.game.ai.tasks.PriorityTask;
Expand Down Expand Up @@ -44,7 +45,7 @@ public class DemonBossTask extends DefaultTask implements PriorityTask {
private Entity demon;
private float elapsedTime = 0f;
private boolean sequenceFlag = false;
private Double[] yArray = {Math.sqrt(3), 1/Math.sqrt(3), -1/Math.sqrt(3), -Math.sqrt(3)};
Array<Double> yArray = new Array<>();

private enum DEMON_STATE {
TRANSFORM, IDLE, CAST, CLEAVE, DEATH, BREATH, SMASH, TAKE_HIT, WALK
Expand Down Expand Up @@ -90,6 +91,7 @@ public void update() {
jump(getJumpPos());
if (jumpComplete()) {
fireBreath();
sequenceFlag = false;
}

}
Expand Down Expand Up @@ -175,14 +177,26 @@ private boolean jumpComplete() {

private void fireBreath() {
changeState(DEMON_STATE.BREATH);
Vector2 destination = null;

// add constant y changes to burn projectile
yArray.add(Math.sqrt(3));
yArray.add(1/Math.sqrt(3));
yArray.add(1d);
yArray.add(-1/Math.sqrt(3));
yArray.add(-Math.sqrt(3));

// spawn breath balls
for (int i = 0; i < BURN_BALLS; i++) {

// calculate destination of burn balls
float x = demon.getPosition().x - X_LENGTH;
float y = (float) (demon.getPosition().y + yArray[i] * X_LENGTH);
destination = new Vector2(x, y);
float y = (float) (demon.getPosition().y + yArray.get(i) * X_LENGTH);
Vector2 destination = new Vector2(x, y);

// create burn projectiles
Entity projectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.HUMANS, destination,
new Vector2(2,2), ProjectileEffects.BURN, false);
projectile.setPosition(demon.getPosition().x, demon.getPosition().y);
}
Entity projectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.HUMANS, destination,
new Vector2(2,2), ProjectileEffects.BURN, false);
projectile.setPosition(demon.getPosition().x, demon.getPosition().y);
}
}

0 comments on commit 80a2c6c

Please sign in to comment.