sons désactivables
This commit is contained in:
parent
ad4b9ffb99
commit
0a996e6d0a
|
@ -1,5 +1,6 @@
|
||||||
package sagittarius.model;
|
package sagittarius.model;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
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.MathUtils;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
import com.badlogic.gdx.audio.Sound;
|
||||||
|
|
||||||
import sagittarius.SagittariusGame;
|
import sagittarius.SagittariusGame;
|
||||||
import sagittarius.view.GameScreen;
|
import sagittarius.view.GameScreen;
|
||||||
|
@ -28,6 +30,8 @@ public class Arrow extends EntityQuad {
|
||||||
private Planet crash;
|
private Planet crash;
|
||||||
private Vector2 offset;
|
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;
|
private Texture texture;
|
||||||
|
|
||||||
// ---------- CONSTRUCTORs ----------
|
// ---------- CONSTRUCTORs ----------
|
||||||
|
@ -158,6 +162,13 @@ public class Arrow extends EntityQuad {
|
||||||
Planet planet = (Planet) actor;
|
Planet planet = (Planet) actor;
|
||||||
if (planet.hitbox.contains(this.getPosition())) {
|
if (planet.hitbox.contains(this.getPosition())) {
|
||||||
landed = true;
|
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.crash = planet;
|
||||||
this.offset = this.getPosition().sub( planet.getPosition() );
|
this.offset = this.getPosition().sub( planet.getPosition() );
|
||||||
GameScreen.nextPlayer();
|
GameScreen.nextPlayer();
|
||||||
|
@ -186,11 +197,19 @@ public class Arrow extends EntityQuad {
|
||||||
if (player == GameScreen.playerCurrent && TTL > 19.5) continue;
|
if (player == GameScreen.playerCurrent && TTL > 19.5) continue;
|
||||||
if (Intersector.overlapConvexPolygons(player.hitbox, this.hitbox)) {
|
if (Intersector.overlapConvexPolygons(player.hitbox, this.hitbox)) {
|
||||||
landed = true;
|
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.removePlayer(player);
|
||||||
GameScreen.arrows.removeActor(this);
|
GameScreen.arrows.removeActor(this);
|
||||||
GameScreen.nextPlayer();
|
GameScreen.nextPlayer();
|
||||||
GameScreen.setFocus(GameScreen.playerCurrent);
|
GameScreen.setFocus(GameScreen.playerCurrent);
|
||||||
|
// Make a sound when an arrow touched
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,6 +219,7 @@ public class Arrow extends EntityQuad {
|
||||||
Player player = (Player) actor;
|
Player player = (Player) actor;
|
||||||
if (player == GameScreen.playerCurrent) continue;
|
if (player == GameScreen.playerCurrent) continue;
|
||||||
if (player.hitbox.contains(this.getPosition())) {
|
if (player.hitbox.contains(this.getPosition())) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,7 +240,9 @@ public class Arrow extends EntityQuad {
|
||||||
for (int i = 0; i < iterations; i++) {
|
for (int i = 0; i < iterations; i++) {
|
||||||
dummyArrow.integrationVerlet(timeStep);
|
dummyArrow.integrationVerlet(timeStep);
|
||||||
traj.add(dummyArrow.getPosition());
|
traj.add(dummyArrow.getPosition());
|
||||||
if ( dummyArrow.hasLanded() || dummyArrow.hasHit() ) { break; }
|
if ( dummyArrow.hasLanded() || dummyArrow.hasHit() ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return traj;
|
return traj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,15 @@ public class ResumeScreen extends BaseScreen {
|
||||||
SagittariusGame.disableMusic = false;
|
SagittariusGame.disableMusic = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deactivate music or not
|
||||||
|
if (disableSounds.isChecked() ){
|
||||||
|
SagittariusGame.disableSounds = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
SagittariusGame.disableSounds= false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,14 @@ public class SettingsScreen extends BaseScreen {
|
||||||
SagittariusGame.disableMusic = false;
|
SagittariusGame.disableMusic = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deactivate music or not
|
||||||
|
if (disableSounds.isChecked() ){
|
||||||
|
SagittariusGame.disableSounds = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
SagittariusGame.disableSounds= false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue