Skip to content

Commit

Permalink
added boundary checking for spawning demon slimes and added new sound…
Browse files Browse the repository at this point in the history
… for it
  • Loading branch information
gregchan550 committed Oct 9, 2023
1 parent aee3fd2 commit f9f9790
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ public class ForestGameArea extends GameArea {
"sounds/mobBoss/patrickSpawn.mp3",
"sounds/mobBoss/patrickCast.mp3",
"sounds/mobBoss/patrickThunder.mp3",
"sounds/mobBoss/patrickHit.mp3"
"sounds/mobBoss/patrickHit.mp3",
"sounds/mobBoss/spawnDemonSlime.mp3"
};
private static final String backgroundMusic = "sounds/background/Sci-Fi1.ogg";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class DemonAnimationController extends Component {
"sounds/mobBoss/slimeJump.mp3", Sound.class);
Sound slimePop = ServiceLocator.getResourceService().getAsset(
"sounds/mobBoss/slimePop.mp3", Sound.class);
Sound spawnDemonSlime = ServiceLocator.getResourceService().getAsset(
"sounds/mobBoss/spawnDemonSlime.mp3", Sound.class);

/**
* Creation call for a DemonAnimationController, fetches the animationRenderComponent that this controller will
Expand Down Expand Up @@ -66,6 +68,7 @@ public void create() {
entity.getEvents().addListener("slimey_splat_sound", this::slimeySplatSound);
entity.getEvents().addListener("slime_jump_sound", this::slimeJumpSound);
entity.getEvents().addListener("slime_pop_sound", this::slimePopSound);
entity.getEvents().addListener("spawn_demon_slime", this::spawnDemonSlimeSound);
}

private void demonWalk() {
Expand Down Expand Up @@ -156,4 +159,8 @@ private void slimePopSound() {
slimePop.setVolume(1000,5.5f);
slimePop.play();
}
private void spawnDemonSlimeSound() {
spawnDemonSlime.setVolume(1000,5.5f);
spawnDemonSlime.play();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class DemonBossTask extends DefaultTask implements PriorityTask {
private static final int HEAL_TIMES = 10;
private static final int HEALTH_TO_ADD = 10;
private static final int SLIMEY_BOY_HEALTH = 500;
private static final int SLIMES_SPAWNED = 1;
private static final int SLIMES_SPAWNED = 2;
private static final int SPAWN_RADIUS = 2;

// Private variables
Expand Down Expand Up @@ -480,6 +480,15 @@ public void run() {
float x = demon.getPosition().x + distance * MathUtils.cos(angle);
float y = demon.getPosition().y + distance * MathUtils.sin(angle);

// boundary check
if (x > xRightBoundary || x < xLeftBoundary) {
x = demon.getPosition().x;
}
if (y > Y_TOP_BOUNDARY || y < Y_BOT_BOUNDARY) {
y = demon.getPosition().y;
}

demon.getEvents().trigger("spawn_demon_slime");
Vector2 spawnLocation = new Vector2(x, y);
slime.setPosition(spawnLocation);
ServiceLocator.getEntityService().register(slime);
Expand All @@ -488,7 +497,7 @@ public void run() {
isSpawning = false;
}
}
}, (float) i /2);
}, (float) (i + 1) * 2);
}
}
}
Expand Down

0 comments on commit f9f9790

Please sign in to comment.