chore: formatting

This commit is contained in:
Laureηt 2021-05-27 11:04:00 +02:00
parent 3c351ac996
commit b76cb1d159
19 changed files with 447 additions and 382 deletions

15
.editorconfig Normal file
View file

@ -0,0 +1,15 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# 4 space indentation
[*.java]
indent_style = space
indent_size = 4

View file

@ -55,8 +55,10 @@ public class Arrow extends EntityQuad {
if (!preview) {
arrowLandedSound = Gdx.audio.newSound(Gdx.files.internal("sounds/effects/arrow_landed.mp3"));
arrowHitSound = Gdx.audio.newSound(Gdx.files.internal("sounds/effects/player_death.wav"));
arrowLandedSound =
Gdx.audio.newSound(Gdx.files.internal("sounds/effects/arrow_landed.mp3"));
arrowHitSound =
Gdx.audio.newSound(Gdx.files.internal("sounds/effects/player_death.wav"));
texture = new ArrayList<>();
String path = "arrow" + MathUtils.random(2);
@ -119,7 +121,8 @@ public class Arrow extends EntityQuad {
public void drawDebug(ShapeRenderer shapes) {
super.drawDebug(shapes);
if (!landed) {
if (getStage() != null) shapes.setColor(getStage().getDebugColor());
if (getStage() != null)
shapes.setColor(getStage().getDebugColor());
for (Actor actor : GameScreen.attractors.getChildren()) {
shapes.line(getX(), getY(), actor.getX(), actor.getY());
}
@ -129,14 +132,16 @@ public class Arrow extends EntityQuad {
@Override
public void draw(Batch batch, float parentAlpha) {
int i = (int) (TTL * 3) % texture.size();
batch.draw(texture.get(i), getPosition().x - getOriginX(), getPosition().y - getWidth()/2, getOriginX(), getWidth()/2, getWidth(), getWidth(),
1, 1, getRotation(), 0, 0, texture.get(i).getWidth(), texture.get(i).getHeight(), false, false);
batch.draw(texture.get(i), getPosition().x - getOriginX(), getPosition().y - getWidth() / 2,
getOriginX(), getWidth() / 2, getWidth(), getWidth(), 1, 1, getRotation(), 0, 0,
texture.get(i).getWidth(), texture.get(i).getHeight(), false, false);
super.draw(batch, parentAlpha);
}
/**
* Computes the {@link Arrow#force} exerted on the Arrow,
* according to the other weighted entities.
* Computes the {@link Arrow#force} exerted on the Arrow, according to the other weighted
* entities.
*
* @return the complete force exerted on the Arrow.
*/
private Vector2 computeForce() {
@ -151,12 +156,12 @@ public class Arrow extends EntityQuad {
}
/**
* Computes the next position of the Arrow
* according to its physical attributes
* using the Verlet integration scheme.
* Computes the next position of the Arrow according to its physical attributes using the Verlet
* integration scheme.
*
* @param dt time difference used in the integration.
* @see <a href="https://gamedev.stackexchange.com/a/41917">https://gamedev.stackexchange.com/a/41917</a>.
* @see <a href=
* "https://gamedev.stackexchange.com/a/41917">https://gamedev.stackexchange.com/a/41917</a>.
*/
private void integrationVerlet(float dt) {
@ -211,13 +216,13 @@ public class Arrow extends EntityQuad {
private void verifyHitting() {
for (Actor actor : GameScreen.players.getChildren()) {
Player player = (Player) actor;
if (player == GameScreen.playerCurrent && TTL > 19.5) continue;
if (player == GameScreen.playerCurrent && TTL > 19.5)
continue;
if (Intersector.overlapConvexPolygons(player.hitbox, this.hitbox)) {
// Make a sound when an arrow killed somebody
// Make a sound when an arrow kills somebody
if (!SagittariusGame.disableSounds) {
long shotid = arrowHitSound.play(SagittariusGame.soundsVolume);
arrowHitSound.setPitch(shotid,1.5f);
arrowHitSound.play(SagittariusGame.soundsVolume);
}
GameScreen.removePlayer(player);
@ -230,24 +235,26 @@ public class Arrow extends EntityQuad {
private boolean hasHit() {
for (Actor actor : GameScreen.players.getChildren()) {
Player player = (Player) actor;
if (player == GameScreen.playerCurrent) continue;
if (player == GameScreen.playerCurrent)
continue;
if (player.hitbox.contains(this.getPosition())) {
return true;
}
}
return false;
}
/** // TODO : pass directly an Arrow instead of 3 arguments
* Computes the trajectory of an Arrow,
* given its initial conditions.
/**
* // TODO : pass directly an Arrow instead of 3 arguments
*
* Computes the trajectory of an Arrow, given its initial conditions.
*
* @param iterations number of iterations for the integration.
* @param timeStep time period used for the integration.
* @return an array of vertices describing the trajectory of the Arrow.
*/
static Trajectory computeTrajectory(float angle, float power, Player shooter, int iterations, float timeStep) {
static Trajectory computeTrajectory(float angle, float power, Player shooter, int iterations,
float timeStep) {
Trajectory traj = new Trajectory(iterations); // TODO: not optimal
Arrow dummyArrow = new Arrow(angle, power, shooter, true);
for (int i = 0; i < iterations; i++) {
@ -262,22 +269,14 @@ public class Arrow extends EntityQuad {
@Override
protected String getInfo() {
if (landed) {
return
"TTL=" + (int)TTL + "\n"
+ "pos=" + (int)getX() + "," + (int)getY() + "\n"
+ "angle=" + (int)getRotation()
;
return "TTL=" + (int) TTL + "\n" + "pos=" + (int) getX() + "," + (int) getY() + "\n"
+ "angle=" + (int) getRotation();
} else {
return
"TTL=" + (int)TTL + "\n"
+ "pos=" + (int)getX() + "," + (int)getY() + "\n"
+ "speed=" + (int)velocity.x + "," + (int)velocity.y + "\n"
+ "accel=" + (int)acceleration.x + "," + (int)acceleration.y +"\n"
+ "force=" + (int)force.x + "," + (int)force.y + "\n"
+ "angle=" + (int)getRotation()
;
return "TTL=" + (int) TTL + "\n" + "pos=" + (int) getX() + "," + (int) getY() + "\n"
+ "speed=" + (int) velocity.x + "," + (int) velocity.y + "\n" + "accel="
+ (int) acceleration.x + "," + (int) acceleration.y + "\n" + "force="
+ (int) force.x + "," + (int) force.y + "\n" + "angle=" + (int) getRotation();
}
}

View file

@ -18,7 +18,8 @@ public class Bow extends Actor {
private boolean aimAssist = false;
private boolean pressed = false;
private float angle;
private Sound shotSound = Gdx.audio.newSound(Gdx.files.internal("sounds/effects/arrow_shot.mp3"));
private Sound shotSound =
Gdx.audio.newSound(Gdx.files.internal("sounds/effects/arrow_shot.mp3"));
private Vector2 anchor = new Vector2();
private Vector2 aim = new Vector2();
@ -36,7 +37,8 @@ public class Bow extends Actor {
@Override
public void act(float dt) {
super.act(dt);
if (GameScreen.playerCurrent.isActive() && Gdx.input.isButtonJustPressed(SagittariusGame.shootArrowButton) && !pressed) {
if (GameScreen.playerCurrent.isActive()
&& Gdx.input.isButtonJustPressed(SagittariusGame.shootArrowButton) && !pressed) {
this.anchor = GameScreen.worldCursor.cpy();
pressed = true;
} else if (Gdx.input.isButtonPressed(SagittariusGame.shootArrowButton) && pressed) {
@ -64,10 +66,12 @@ public class Bow extends Actor {
public void drawDebug(ShapeRenderer shapes) {
super.drawDebug(shapes);
if (pressed) {
if (power > 50) shapes.setColor(Color.RED);
if (power > 50)
shapes.setColor(Color.RED);
shapes.line(this.anchor, GameScreen.worldCursor);
if (aimAssist) {
Trajectory traj = Arrow.computeTrajectory(angle, power, GameScreen.playerCurrent, 500, 0.03f);
Trajectory traj =
Arrow.computeTrajectory(angle, power, GameScreen.playerCurrent, 500, 0.03f);
shapes.polyline(traj.path, 0, traj.actualSize);
}
}

View file

@ -30,7 +30,9 @@ public abstract class Entity extends Actor {
// ---------- CONSTRUCTORs ----------
/** Creates an {@link #Entity}.
/**
* Creates an {@link #Entity}.
*
* @param angle angle associated to the {@link #Entity}.
* @param mass mass of the {@link #Entity}.
* @param color color of the {@link #Entity}.
@ -106,6 +108,7 @@ public abstract class Entity extends Actor {
/**
* inpired from {@link ShapeRenderer#rect}
*
* @return vertices of the hitbox polygon
*/
protected abstract float[] getHitbox();
@ -119,12 +122,14 @@ public abstract class Entity extends Actor {
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
if (getDebug()) GameScreen.fontDebug.draw(batch, getInfo(), getX(), getY());
if (getDebug())
GameScreen.fontDebug.draw(batch, getInfo(), getX(), getY());
}
@Override
protected void drawDebugBounds(ShapeRenderer shapes) {
if (!getDebug()) return;
if (!getDebug())
return;
shapes.set(ShapeType.Line);
shapes.setColor(this.getColor());
shapes.polygon(hitbox.getVertices());

View file

@ -12,7 +12,9 @@ public abstract class EntityCircle extends Entity {
// ---------- CONSTRUCTORs ----------
/** Creates an {@link #Entity}.
/**
* Creates an {@link #Entity}.
*
* @param angle angle associated to the {@link #Entity}.
* @param mass mass of the {@link #Entity}.
* @param color color of the {@link #Entity}.
@ -52,7 +54,8 @@ public abstract class EntityCircle extends Entity {
float theta = 360.0f / segments;
for (int i = 0; i < segments; i++) {
vertices[2 * i] = getX() + MathUtils.cosDeg(theta * (i + 1) + getRotation()) * radius;
vertices[2*i+1] = getY() + MathUtils.sinDeg(theta * (i+1) + getRotation())*radius;
vertices[2 * i + 1] =
getY() + MathUtils.sinDeg(theta * (i + 1) + getRotation()) * radius;
}
return vertices;

View file

@ -8,7 +8,9 @@ public abstract class EntityQuad extends Entity {
// ---------- CONSTRUCTORs ----------
/** Creates an {@link #Entity}.
/**
* Creates an {@link #Entity}.
*
* @param angle angle associated to the {@link #Entity}.
* @param mass mass of the {@link #Entity}.
* @param color color of the {@link #Entity}.

View file

@ -41,7 +41,8 @@ public class Moon extends Planet {
@Override
public void drawDebug(ShapeRenderer shapes) {
super.drawDebug(shapes);
if (getStage() != null) shapes.setColor(getStage().getDebugColor());
if (getStage() != null)
shapes.setColor(getStage().getDebugColor());
shapes.line(getX(), getY(), sun.getX(), sun.getY());
}

View file

@ -71,19 +71,18 @@ public class Planet extends EntityCircle {
@Override
protected String getInfo() {
return
"radius=" + (int)radius + "\n"
+ "mass=" + (int)mass + "\n"
+ "pos=" + (int)getX() + "," + (int)getY()
;
return "radius=" + (int) radius + "\n" + "mass=" + (int) mass + "\n" + "pos=" + (int) getX()
+ "," + (int) getY();
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.draw(backGround, getPosition().x - this.radius, getPosition().y - this.radius, this.radius, this.radius, 2 * this.radius, 2 * this.radius,
1, 1, getRotation(), 0, 0, texture.getWidth(), texture.getHeight(), false, false);
batch.draw(texture, getPosition().x - this.radius, getPosition().y - this.radius, this.radius, this.radius, 2 * this.radius, 2 * this.radius,
1, 1, getRotation(), 0, 0, texture.getWidth(), texture.getHeight(), false, false);
batch.draw(backGround, getPosition().x - this.radius, getPosition().y - this.radius,
this.radius, this.radius, 2 * this.radius, 2 * this.radius, 1, 1, getRotation(), 0,
0, texture.getWidth(), texture.getHeight(), false, false);
batch.draw(texture, getPosition().x - this.radius, getPosition().y - this.radius,
this.radius, this.radius, 2 * this.radius, 2 * this.radius, 1, 1, getRotation(), 0,
0, texture.getWidth(), texture.getHeight(), false, false);
super.draw(batch, parentAlpha);
}

View file

@ -67,7 +67,8 @@ public class Player extends EntityQuad {
@Override
public void drawDebug(ShapeRenderer shapes) {
super.drawDebug(shapes);
if (getStage() != null) shapes.setColor(getStage().getDebugColor());
if (getStage() != null)
shapes.setColor(getStage().getDebugColor());
shapes.line(home.getX(), home.getY(), getX(), getY());
}
@ -77,8 +78,10 @@ public class Player extends EntityQuad {
T %= 100;
int i = (int) (T * ((float) texture.size() / 100));
batch.draw(texture.get(i), getPosition().x - getWidth()/2, getPosition().y - getHeight()/2, getWidth()/2, getHeight()/2, getWidth(), getHeight(),
1, 1, getRotation(), 0, 0, texture.get(i).getWidth(), texture.get(i).getHeight(), false, false);
batch.draw(texture.get(i), getPosition().x - getWidth() / 2,
getPosition().y - getHeight() / 2, getWidth() / 2, getHeight() / 2, getWidth(),
getHeight(), 1, 1, getRotation(), 0, 0, texture.get(i).getWidth(),
texture.get(i).getHeight(), false, false);
super.draw(batch, parentAlpha);
}
@ -95,17 +98,17 @@ public class Player extends EntityQuad {
}
}
setX(home.getX() + (home.getRadius() + getHeight()/2)*MathUtils.cosDeg(home.getRotation() + angle));
setY(home.getY() + (home.getRadius() + getHeight()/2)*MathUtils.sinDeg(home.getRotation() + angle));
setX(home.getX() + (home.getRadius() + getHeight() / 2)
* MathUtils.cosDeg(home.getRotation() + angle));
setY(home.getY() + (home.getRadius() + getHeight() / 2)
* MathUtils.sinDeg(home.getRotation() + angle));
this.setRotation(home.getRotation() + angle - 90);
}
@Override
protected String getInfo() {
return
"pos=" + (int)getX() + "," + (int)getY()
;
return "pos=" + (int) getX() + "," + (int) getY();
}
/**
@ -117,6 +120,7 @@ public class Player extends EntityQuad {
/**
* Change the active state of the {@link Player}.
*
* @param bool true or false
*/
public void setActive(boolean bool) {

View file

@ -22,6 +22,7 @@ public abstract class BaseScreen implements Screen {
}
public abstract void initialize();
public abstract void update(float dt);
@Override
@ -43,20 +44,30 @@ public abstract class BaseScreen implements Screen {
uiStage.draw();
}
@Override public void dispose() {
@Override
public void dispose() {
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("sounds/Ghostrifter-Deflector.mp3"));
SagittariusGame.music =
Gdx.audio.newMusic(Gdx.files.internal("sounds/Ghostrifter-Deflector.mp3"));
uiStage.dispose();
mainStage.dispose();
}
@Override public void resize(int width, int height) {
@Override
public void resize(int width, int height) {
mainStage.getViewport().update(width, height, true);
}
@Override public void pause() {}
@Override public void resume() {}
@Override public void show() {}
@Override public void hide() {}
@Override
public void pause() {}
@Override
public void resume() {}
@Override
public void show() {}
@Override
public void hide() {}
}

View file

@ -18,7 +18,8 @@ public class CreditScreen extends BaseScreen {
if (!SagittariusGame.disableMusic) {
SagittariusGame.music.stop();
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("sounds/music/credit_music.mp3"));
SagittariusGame.music =
Gdx.audio.newMusic(Gdx.files.internal("sounds/music/credit_music.mp3"));
SagittariusGame.music.setLooping(true);
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
SagittariusGame.music.play();

View file

@ -27,7 +27,8 @@ public class FPS extends Actor {
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
if (getDebug()) GameScreen.fontDebug.draw(batch, getInfo(), getX(), getY());
if (getDebug())
GameScreen.fontDebug.draw(batch, getInfo(), getX(), getY());
}
protected String getInfo() {

View file

@ -51,7 +51,8 @@ public class GameScreen extends BaseScreen implements InputProcessor {
if (!SagittariusGame.disableMusic) {
SagittariusGame.music.stop();
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("sounds/music/game_music.mp3"));
SagittariusGame.music =
Gdx.audio.newMusic(Gdx.files.internal("sounds/music/game_music.mp3"));
SagittariusGame.music.setLooping(true);
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
SagittariusGame.music.play();
@ -124,7 +125,8 @@ public class GameScreen extends BaseScreen implements InputProcessor {
@Override
public void update(float dt) {
screenCursor = new Vector2(Gdx.input.getX(), Gdx.input.getY()); // utiliser les trucs fournis par libGDX
screenCursor = new Vector2(Gdx.input.getX(), Gdx.input.getY()); // utiliser les trucs
// fournis par libGDX
unprojectedCursor = mainStage.getCamera().unproject(new Vector3(screenCursor, 0));
worldCursor = new Vector2(unprojectedCursor.x, unprojectedCursor.y);

View file

@ -18,14 +18,14 @@ public class MouseInfo extends Actor {
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
if (getDebug()) GameScreen.fontDebug.draw(batch, getInfo(), getX(), getY());
if (getDebug())
GameScreen.fontDebug.draw(batch, getInfo(), getX(), getY());
}
protected String getInfo() {
return
"screen=" + (int)GameScreen.screenCursor.x + "," + (int)GameScreen.screenCursor.y + "\n"
+ "world=" + (int)GameScreen.worldCursor.x + "," + (int)GameScreen.worldCursor.y
;
return "screen=" + (int) GameScreen.screenCursor.x + "," + (int) GameScreen.screenCursor.y
+ "\n" + "world=" + (int) GameScreen.worldCursor.x + ","
+ (int) GameScreen.worldCursor.y;
}
}

View file

@ -24,7 +24,8 @@ public class ResumeScreen extends BaseScreen {
if (!SagittariusGame.disableMusic) {
SagittariusGame.music.stop();
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("sounds/music/resumeMenu_music.mp3"));
SagittariusGame.music =
Gdx.audio.newMusic(Gdx.files.internal("sounds/music/resumeMenu_music.mp3"));
SagittariusGame.music.setLooping(true);
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
SagittariusGame.music.play();
@ -41,14 +42,16 @@ public class ResumeScreen extends BaseScreen {
disableMusic.setChecked(SagittariusGame.disableMusic);
// Change volume of the music
SpinnerSounded musicVolume= new SpinnerSounded("Music Volume:", new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3));
SpinnerSounded musicVolume = new SpinnerSounded("Music Volume:",
new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3));
// disable sound checkbox
CheckBoxSounded disableSounds = new CheckBoxSounded("disable sounds");
disableSounds.setChecked(SagittariusGame.disableSounds);
// Change volume of the sound
SpinnerSounded musicSounds= new SpinnerSounded("Sounds Volume:", new SimpleFloatSpinnerModel(SagittariusGame.soundsVolume, 0f, 1.0f, 0.01f, 3));
SpinnerSounded musicSounds = new SpinnerSounded("Sounds Volume:",
new SimpleFloatSpinnerModel(SagittariusGame.soundsVolume, 0f, 1.0f, 0.01f, 3));
// save button
ButtonTextSounded applyButton = new ButtonTextSounded("Apply");
@ -57,16 +60,18 @@ public class ResumeScreen extends BaseScreen {
public void tap(InputEvent event, float x, float y, int count, int button) {
super.tap(event, x, y, count, button);
SagittariusGame.music.setVolume(Float.parseFloat(musicVolume.getTextField().getText()));
SagittariusGame.musicVolume = Float.parseFloat(musicVolume.getTextField().getText());
SagittariusGame.soundsVolume = Float.parseFloat(musicSounds.getTextField().getText());
SagittariusGame.music
.setVolume(Float.parseFloat(musicVolume.getTextField().getText()));
SagittariusGame.musicVolume =
Float.parseFloat(musicVolume.getTextField().getText());
SagittariusGame.soundsVolume =
Float.parseFloat(musicSounds.getTextField().getText());
// Deactivate music or not
if (disableMusic.isChecked() && SagittariusGame.music.isPlaying()) {
SagittariusGame.music.stop();
SagittariusGame.disableMusic = true;
}
else if (!disableMusic.isChecked() && ! SagittariusGame.music.isPlaying()){
} else if (!disableMusic.isChecked() && !SagittariusGame.music.isPlaying()) {
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
SagittariusGame.music.play();
SagittariusGame.disableMusic = false;
@ -93,7 +98,8 @@ public class ResumeScreen extends BaseScreen {
if (!SagittariusGame.disableMusic) {
SagittariusGame.music.stop();
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("sounds/music/game_music.mp3"));
SagittariusGame.music =
Gdx.audio.newMusic(Gdx.files.internal("sounds/music/game_music.mp3"));
SagittariusGame.music.setLooping(true);
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
SagittariusGame.music.play();

View file

@ -23,7 +23,8 @@ public class SettingsScreen extends BaseScreen {
if (!SagittariusGame.disableMusic) {
SagittariusGame.music.stop();
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("sounds/music/resumeMenu_music.mp3"));
SagittariusGame.music =
Gdx.audio.newMusic(Gdx.files.internal("sounds/music/resumeMenu_music.mp3"));
SagittariusGame.music.setLooping(true);
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
SagittariusGame.music.play();
@ -37,7 +38,8 @@ public class SettingsScreen extends BaseScreen {
uiStage.addActor(table);
// G constant field
SpinnerSounded gConstField = new SpinnerSounded("G constant:", new SimpleFloatSpinnerModel(SagittariusGame.G, 1f, 500f, 0.5f, 3));
SpinnerSounded gConstField = new SpinnerSounded("G constant:",
new SimpleFloatSpinnerModel(SagittariusGame.G, 1f, 500f, 0.5f, 3));
// dubug mode checkbox
CheckBoxSounded debugModeBox = new CheckBoxSounded("debug mode");
@ -48,14 +50,16 @@ public class SettingsScreen extends BaseScreen {
disableMusic.setChecked(SagittariusGame.disableMusic);
// Change volume of the music
SpinnerSounded musicVolume= new SpinnerSounded("Music Volume:", new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3));
SpinnerSounded musicVolume = new SpinnerSounded("Music Volume:",
new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3));
// disable sound checkbox
CheckBoxSounded disableSounds = new CheckBoxSounded("disable sounds");
disableSounds.setChecked(SagittariusGame.disableSounds);
// Change volume of the sound
SpinnerSounded musicSounds= new SpinnerSounded("Sounds Volume:", new SimpleFloatSpinnerModel(SagittariusGame.soundsVolume, 0f, 1.0f, 0.01f, 3));
SpinnerSounded musicSounds = new SpinnerSounded("Sounds Volume:",
new SimpleFloatSpinnerModel(SagittariusGame.soundsVolume, 0f, 1.0f, 0.01f, 3));
// go back button
ButtonTextSounded returnButton = new ButtonTextSounded("Go Back");
@ -77,6 +81,7 @@ public class SettingsScreen extends BaseScreen {
shootArrow.addListener(new ClickListener() {
private boolean capturing = false;
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (!shootArrow.isDisabled() && !capturing && button == Buttons.LEFT) {
@ -110,23 +115,28 @@ public class SettingsScreen extends BaseScreen {
super.tap(event, x, y, count, button);
SagittariusGame.G = Float.parseFloat(gConstField.getTextField().getText());
SagittariusGame.music.setVolume(Float.parseFloat(musicVolume.getTextField().getText()));
SagittariusGame.musicVolume= Float.parseFloat(musicVolume.getTextField().getText());
SagittariusGame.soundsVolume = Float.parseFloat(musicSounds.getTextField().getText());
SagittariusGame.music
.setVolume(Float.parseFloat(musicVolume.getTextField().getText()));
SagittariusGame.musicVolume =
Float.parseFloat(musicVolume.getTextField().getText());
SagittariusGame.soundsVolume =
Float.parseFloat(musicSounds.getTextField().getText());
SagittariusGame.debugMode = debugModeBox.isChecked();
SagittariusGame.moveLeftKey = Keys.valueOf(moveLeft.getText().toString());
SagittariusGame.moveRightKey = Keys.valueOf(moveRight.getText().toString());
SagittariusGame.zoomInKey = Keys.valueOf(zoomIn.getText().toString());
SagittariusGame.zoomOutKey = Keys.valueOf(zoomOut.getText().toString());
SagittariusGame.shootArrowButton = Keys.valueOf(shootArrow.getText().toString().substring(5));
SagittariusGame.shootArrowButton =
Keys.valueOf(shootArrow.getText().toString().substring(5));
// Deactivate music or not
if (disableMusic.isChecked() && SagittariusGame.music.isPlaying()) {
SagittariusGame.music.stop();
SagittariusGame.disableMusic = true;
} else if (!disableMusic.isChecked() && !SagittariusGame.music.isPlaying()) {
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("sounds/music/resumeMenu_music.mp3"));
SagittariusGame.music = Gdx.audio
.newMusic(Gdx.files.internal("sounds/music/resumeMenu_music.mp3"));
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
SagittariusGame.music.play();
SagittariusGame.disableMusic = false;

View file

@ -18,7 +18,8 @@ public class StartScreen extends BaseScreen {
if (!SagittariusGame.disableMusic) {
if (SagittariusGame.music != null) {
SagittariusGame.music.stop();
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("sounds/music/mainMenu_music.mp3"));
SagittariusGame.music =
Gdx.audio.newMusic(Gdx.files.internal("sounds/music/mainMenu_music.mp3"));
SagittariusGame.music.setLooping(true);
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
SagittariusGame.music.play();
@ -26,7 +27,8 @@ public class StartScreen extends BaseScreen {
}
else {
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("sounds/music/mainMenu_music.mp3"));
SagittariusGame.music =
Gdx.audio.newMusic(Gdx.files.internal("sounds/music/mainMenu_music.mp3"));
SagittariusGame.music.setLooping(true);
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
SagittariusGame.music.play();