Skip to content

Commit

Permalink
cleaned up fireBreath animation
Browse files Browse the repository at this point in the history
  • Loading branch information
gregchan550 committed Sep 20, 2023
1 parent e8ea745 commit 1416874
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,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 @@ -31,10 +31,11 @@ public class DemonBossTask extends DefaultTask implements PriorityTask {
private static final int BURN_BALLS = 5;
private static final int X_LENGTH = 20; // for projectile destination calculations
private static final float JUMP_DISTANCE = 3.0f;
private static final int xRightBoundary = 17;
private static final int xLeftBoundary = 1;
private static final int yTopBoundary = 6;
private static final int yBotBoundary = 1;
private static final int X_RIGHT_BOUNDARY = 17;
private static final int X_LEFT_BOUNDARY = 1;
private static final int Y_TOP_BOUNDARY = 6;
private static final int Y_BOT_BOUNDARY = 1;
private static final int BREATH_ANIM_TIME = 2;

// Private variables
private static final Logger logger = LoggerFactory.getLogger(DemonBossTask.class);
Expand All @@ -51,7 +52,7 @@ public class DemonBossTask extends DefaultTask implements PriorityTask {
private boolean waitFlag = false;
private boolean timerFlag;
private int numBalls = 5;
private ProjectileEffects effect = ProjectileEffects.FIREBALL;
private ProjectileEffects effect = ProjectileEffects.BURN;
private boolean aoe = true;

// Enums
Expand Down Expand Up @@ -193,8 +194,8 @@ private Vector2 getJumpPos() {
float y = JUMP_DISTANCE * MathUtils.sin(randomAngle);

// check boundaries
if (x + currentPos.x > xRightBoundary || x + currentPos.x < xLeftBoundary) { x *= -1; }
if (y + currentPos.y > yTopBoundary || y + currentPos.y < yBotBoundary) { y *= -1; }
if (x + currentPos.x > X_RIGHT_BOUNDARY || x + currentPos.x < X_LEFT_BOUNDARY) { x *= -1; }
if (y + currentPos.y > Y_TOP_BOUNDARY || y + currentPos.y < Y_BOT_BOUNDARY) { y *= -1; }

// get final jump position
float finalX = x + currentPos.x;
Expand Down Expand Up @@ -225,7 +226,7 @@ public void changeBreathAttack(int numBalls, ProjectileEffects effect, boolean a
private void fireBreath() {
changeState(DemonState.BREATH);

long delay = (long) AnimState.BREATH.getDuration() / numBalls;
float delay = (AnimState.BREATH.getDuration() - BREATH_ANIM_TIME) / numBalls;

float startAngle = (float) Math.toRadians(135);
float endAngle = (float) Math.toRadians(225);
Expand All @@ -240,10 +241,15 @@ private void fireBreath() {
Vector2 destination = new Vector2(x, y);

// Create burn projectiles
Entity projectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.HUMANS, destination,
new Vector2(2, 2), effect, aoe);
projectile.setPosition(demon.getPosition().x, demon.getPosition().y);
ServiceLocator.getEntityService().register(projectile);
Timer.schedule(new Timer.Task() {
@Override
public void run() {
Entity projectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.HUMANS, destination,
new Vector2(2, 2), effect, aoe);
projectile.setPosition(demon.getPosition().x, demon.getPosition().y);
ServiceLocator.getEntityService().register(projectile);
}
}, delay * i + BREATH_ANIM_TIME);
}
}
}

0 comments on commit 1416874

Please sign in to comment.