sons désactivables

This commit is contained in:
heurtet 2021-05-14 10:53:28 +02:00
parent ad4b9ffb99
commit 0a996e6d0a
3 changed files with 40 additions and 1 deletions

View file

@ -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;
}

View file

@ -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;
}
}
});

View file

@ -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;
}
}
});