diff --git a/core/src/sagittarius/model/Arrow.java b/core/src/sagittarius/model/Arrow.java index d3f375e..a7e0b51 100644 --- a/core/src/sagittarius/model/Arrow.java +++ b/core/src/sagittarius/model/Arrow.java @@ -1,5 +1,6 @@ package sagittarius.model; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Pixmap; @@ -10,6 +11,7 @@ import com.badlogic.gdx.math.Intersector; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.audio.Sound; import sagittarius.SagittariusGame; import sagittarius.view.GameScreen; @@ -28,6 +30,8 @@ public class Arrow extends EntityQuad { private Planet crash; private Vector2 offset; + private Sound arrowLandedSound = Gdx.audio.newSound(Gdx.files.internal("core/assets/sounds/sf_fleche_plante_01.mp3")); + private Sound arrowHitSound = Gdx.audio.newSound(Gdx.files.internal("core/assets/sounds/VOXScrm_Cri wilhelm (ID 0477)_LS.wav")); private Texture texture; // ---------- CONSTRUCTORs ---------- @@ -158,6 +162,13 @@ public class Arrow extends EntityQuad { Planet planet = (Planet) actor; if (planet.hitbox.contains(this.getPosition())) { landed = true; + + // Make a sound when an arrow lands + if ( ! SagittariusGame.disableSounds){ + long shotid = arrowLandedSound.play(SagittariusGame.soundsVolume); + arrowLandedSound.setPitch(shotid,1.5f); + } + this.crash = planet; this.offset = this.getPosition().sub( planet.getPosition() ); GameScreen.nextPlayer(); @@ -186,11 +197,19 @@ public class Arrow extends EntityQuad { if (player == GameScreen.playerCurrent && TTL > 19.5) continue; if (Intersector.overlapConvexPolygons(player.hitbox, this.hitbox)) { landed = true; + // Make a sound when an arrow killed somebody + if ( ! SagittariusGame.disableSounds){ + long shotid = arrowHitSound.play(SagittariusGame.soundsVolume); + arrowHitSound.setPitch(shotid,1.5f); + } GameScreen.removePlayer(player); GameScreen.arrows.removeActor(this); GameScreen.nextPlayer(); GameScreen.setFocus(GameScreen.playerCurrent); + // Make a sound when an arrow touched + break; + } } } @@ -200,6 +219,7 @@ public class Arrow extends EntityQuad { Player player = (Player) actor; if (player == GameScreen.playerCurrent) continue; if (player.hitbox.contains(this.getPosition())) { + return true; } } @@ -220,7 +240,9 @@ public class Arrow extends EntityQuad { for (int i = 0; i < iterations; i++) { dummyArrow.integrationVerlet(timeStep); traj.add(dummyArrow.getPosition()); - if ( dummyArrow.hasLanded() || dummyArrow.hasHit() ) { break; } + if ( dummyArrow.hasLanded() || dummyArrow.hasHit() ) { + break; + } } return traj; } diff --git a/core/src/sagittarius/view/ResumeScreen.java b/core/src/sagittarius/view/ResumeScreen.java index 3f88f68..29d4b0f 100644 --- a/core/src/sagittarius/view/ResumeScreen.java +++ b/core/src/sagittarius/view/ResumeScreen.java @@ -72,6 +72,15 @@ public class ResumeScreen extends BaseScreen { SagittariusGame.disableMusic = false; } + // Deactivate music or not + if (disableSounds.isChecked() ){ + SagittariusGame.disableSounds = true; + } + + else { + SagittariusGame.disableSounds= false; + } + } }); diff --git a/core/src/sagittarius/view/SettingsScreen.java b/core/src/sagittarius/view/SettingsScreen.java index 1b71414..fa9b356 100644 --- a/core/src/sagittarius/view/SettingsScreen.java +++ b/core/src/sagittarius/view/SettingsScreen.java @@ -77,6 +77,14 @@ public class SettingsScreen extends BaseScreen { SagittariusGame.disableMusic = false; } + // Deactivate music or not + if (disableSounds.isChecked() ){ + SagittariusGame.disableSounds = true; + } + + else { + SagittariusGame.disableSounds= false; + } } });