chore: formatting
This commit is contained in:
parent
3c351ac996
commit
b76cb1d159
15
.editorconfig
Normal file
15
.editorconfig
Normal 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
|
|
@ -55,8 +55,10 @@ public class Arrow extends EntityQuad {
|
||||||
|
|
||||||
if (!preview) {
|
if (!preview) {
|
||||||
|
|
||||||
arrowLandedSound = Gdx.audio.newSound(Gdx.files.internal("sounds/effects/arrow_landed.mp3"));
|
arrowLandedSound =
|
||||||
arrowHitSound = Gdx.audio.newSound(Gdx.files.internal("sounds/effects/player_death.wav"));
|
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<>();
|
texture = new ArrayList<>();
|
||||||
String path = "arrow" + MathUtils.random(2);
|
String path = "arrow" + MathUtils.random(2);
|
||||||
|
@ -119,7 +121,8 @@ public class Arrow extends EntityQuad {
|
||||||
public void drawDebug(ShapeRenderer shapes) {
|
public void drawDebug(ShapeRenderer shapes) {
|
||||||
super.drawDebug(shapes);
|
super.drawDebug(shapes);
|
||||||
if (!landed) {
|
if (!landed) {
|
||||||
if (getStage() != null) shapes.setColor(getStage().getDebugColor());
|
if (getStage() != null)
|
||||||
|
shapes.setColor(getStage().getDebugColor());
|
||||||
for (Actor actor : GameScreen.attractors.getChildren()) {
|
for (Actor actor : GameScreen.attractors.getChildren()) {
|
||||||
shapes.line(getX(), getY(), actor.getX(), actor.getY());
|
shapes.line(getX(), getY(), actor.getX(), actor.getY());
|
||||||
}
|
}
|
||||||
|
@ -129,14 +132,16 @@ public class Arrow extends EntityQuad {
|
||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
int i = (int) (TTL * 3) % texture.size();
|
int i = (int) (TTL * 3) % texture.size();
|
||||||
batch.draw(texture.get(i), getPosition().x - getOriginX(), getPosition().y - getWidth()/2, getOriginX(), getWidth()/2, getWidth(), getWidth(),
|
batch.draw(texture.get(i), getPosition().x - getOriginX(), getPosition().y - getWidth() / 2,
|
||||||
1, 1, getRotation(), 0, 0, texture.get(i).getWidth(), texture.get(i).getHeight(), false, false);
|
getOriginX(), getWidth() / 2, getWidth(), getWidth(), 1, 1, getRotation(), 0, 0,
|
||||||
|
texture.get(i).getWidth(), texture.get(i).getHeight(), false, false);
|
||||||
super.draw(batch, parentAlpha);
|
super.draw(batch, parentAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the {@link Arrow#force} exerted on the Arrow,
|
* Computes the {@link Arrow#force} exerted on the Arrow, according to the other weighted
|
||||||
* according to the other weighted entities.
|
* entities.
|
||||||
|
*
|
||||||
* @return the complete force exerted on the Arrow.
|
* @return the complete force exerted on the Arrow.
|
||||||
*/
|
*/
|
||||||
private Vector2 computeForce() {
|
private Vector2 computeForce() {
|
||||||
|
@ -151,12 +156,12 @@ public class Arrow extends EntityQuad {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the next position of the Arrow
|
* Computes the next position of the Arrow according to its physical attributes using the Verlet
|
||||||
* according to its physical attributes
|
* integration scheme.
|
||||||
* using the Verlet integration scheme.
|
|
||||||
*
|
*
|
||||||
* @param dt time difference used in the integration.
|
* @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) {
|
private void integrationVerlet(float dt) {
|
||||||
|
|
||||||
|
@ -211,13 +216,13 @@ public class Arrow extends EntityQuad {
|
||||||
private void verifyHitting() {
|
private void verifyHitting() {
|
||||||
for (Actor actor : GameScreen.players.getChildren()) {
|
for (Actor actor : GameScreen.players.getChildren()) {
|
||||||
Player player = (Player) actor;
|
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)) {
|
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) {
|
if (!SagittariusGame.disableSounds) {
|
||||||
long shotid = arrowHitSound.play(SagittariusGame.soundsVolume);
|
arrowHitSound.play(SagittariusGame.soundsVolume);
|
||||||
arrowHitSound.setPitch(shotid,1.5f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameScreen.removePlayer(player);
|
GameScreen.removePlayer(player);
|
||||||
|
@ -230,24 +235,26 @@ public class Arrow extends EntityQuad {
|
||||||
private boolean hasHit() {
|
private boolean hasHit() {
|
||||||
for (Actor actor : GameScreen.players.getChildren()) {
|
for (Actor actor : GameScreen.players.getChildren()) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** // TODO : pass directly an Arrow instead of 3 arguments
|
/**
|
||||||
* Computes the trajectory of an Arrow,
|
* // TODO : pass directly an Arrow instead of 3 arguments
|
||||||
* given its initial conditions.
|
*
|
||||||
|
* Computes the trajectory of an Arrow, given its initial conditions.
|
||||||
*
|
*
|
||||||
* @param iterations number of iterations for the integration.
|
* @param iterations number of iterations for the integration.
|
||||||
* @param timeStep time period used for the integration.
|
* @param timeStep time period used for the integration.
|
||||||
* @return an array of vertices describing the trajectory of the Arrow.
|
* @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
|
Trajectory traj = new Trajectory(iterations); // TODO: not optimal
|
||||||
Arrow dummyArrow = new Arrow(angle, power, shooter, true);
|
Arrow dummyArrow = new Arrow(angle, power, shooter, true);
|
||||||
for (int i = 0; i < iterations; i++) {
|
for (int i = 0; i < iterations; i++) {
|
||||||
|
@ -262,22 +269,14 @@ public class Arrow extends EntityQuad {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getInfo() {
|
protected String getInfo() {
|
||||||
|
|
||||||
if (landed) {
|
if (landed) {
|
||||||
return
|
return "TTL=" + (int) TTL + "\n" + "pos=" + (int) getX() + "," + (int) getY() + "\n"
|
||||||
"TTL=" + (int)TTL + "\n"
|
+ "angle=" + (int) getRotation();
|
||||||
+ "pos=" + (int)getX() + "," + (int)getY() + "\n"
|
|
||||||
+ "angle=" + (int)getRotation()
|
|
||||||
;
|
|
||||||
} else {
|
} else {
|
||||||
return
|
return "TTL=" + (int) TTL + "\n" + "pos=" + (int) getX() + "," + (int) getY() + "\n"
|
||||||
"TTL=" + (int)TTL + "\n"
|
+ "speed=" + (int) velocity.x + "," + (int) velocity.y + "\n" + "accel="
|
||||||
+ "pos=" + (int)getX() + "," + (int)getY() + "\n"
|
+ (int) acceleration.x + "," + (int) acceleration.y + "\n" + "force="
|
||||||
+ "speed=" + (int)velocity.x + "," + (int)velocity.y + "\n"
|
+ (int) force.x + "," + (int) force.y + "\n" + "angle=" + (int) getRotation();
|
||||||
+ "accel=" + (int)acceleration.x + "," + (int)acceleration.y +"\n"
|
|
||||||
+ "force=" + (int)force.x + "," + (int)force.y + "\n"
|
|
||||||
+ "angle=" + (int)getRotation()
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@ public class Bow extends Actor {
|
||||||
private boolean aimAssist = false;
|
private boolean aimAssist = false;
|
||||||
private boolean pressed = false;
|
private boolean pressed = false;
|
||||||
private float angle;
|
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 anchor = new Vector2();
|
||||||
private Vector2 aim = new Vector2();
|
private Vector2 aim = new Vector2();
|
||||||
|
|
||||||
|
@ -36,7 +37,8 @@ public class Bow extends Actor {
|
||||||
@Override
|
@Override
|
||||||
public void act(float dt) {
|
public void act(float dt) {
|
||||||
super.act(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();
|
this.anchor = GameScreen.worldCursor.cpy();
|
||||||
pressed = true;
|
pressed = true;
|
||||||
} else if (Gdx.input.isButtonPressed(SagittariusGame.shootArrowButton) && pressed) {
|
} else if (Gdx.input.isButtonPressed(SagittariusGame.shootArrowButton) && pressed) {
|
||||||
|
@ -64,10 +66,12 @@ public class Bow extends Actor {
|
||||||
public void drawDebug(ShapeRenderer shapes) {
|
public void drawDebug(ShapeRenderer shapes) {
|
||||||
super.drawDebug(shapes);
|
super.drawDebug(shapes);
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
if (power > 50) shapes.setColor(Color.RED);
|
if (power > 50)
|
||||||
|
shapes.setColor(Color.RED);
|
||||||
shapes.line(this.anchor, GameScreen.worldCursor);
|
shapes.line(this.anchor, GameScreen.worldCursor);
|
||||||
if (aimAssist) {
|
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);
|
shapes.polyline(traj.path, 0, traj.actualSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,9 @@ public abstract class Entity extends Actor {
|
||||||
|
|
||||||
// ---------- CONSTRUCTORs ----------
|
// ---------- CONSTRUCTORs ----------
|
||||||
|
|
||||||
/** Creates an {@link #Entity}.
|
/**
|
||||||
|
* Creates an {@link #Entity}.
|
||||||
|
*
|
||||||
* @param angle angle associated to the {@link #Entity}.
|
* @param angle angle associated to the {@link #Entity}.
|
||||||
* @param mass mass of the {@link #Entity}.
|
* @param mass mass of the {@link #Entity}.
|
||||||
* @param color color 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}
|
* inpired from {@link ShapeRenderer#rect}
|
||||||
|
*
|
||||||
* @return vertices of the hitbox polygon
|
* @return vertices of the hitbox polygon
|
||||||
*/
|
*/
|
||||||
protected abstract float[] getHitbox();
|
protected abstract float[] getHitbox();
|
||||||
|
@ -119,12 +122,14 @@ public abstract class Entity extends Actor {
|
||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
super.draw(batch, parentAlpha);
|
super.draw(batch, parentAlpha);
|
||||||
if (getDebug()) GameScreen.fontDebug.draw(batch, getInfo(), getX(), getY());
|
if (getDebug())
|
||||||
|
GameScreen.fontDebug.draw(batch, getInfo(), getX(), getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawDebugBounds(ShapeRenderer shapes) {
|
protected void drawDebugBounds(ShapeRenderer shapes) {
|
||||||
if (!getDebug()) return;
|
if (!getDebug())
|
||||||
|
return;
|
||||||
shapes.set(ShapeType.Line);
|
shapes.set(ShapeType.Line);
|
||||||
shapes.setColor(this.getColor());
|
shapes.setColor(this.getColor());
|
||||||
shapes.polygon(hitbox.getVertices());
|
shapes.polygon(hitbox.getVertices());
|
||||||
|
|
|
@ -12,7 +12,9 @@ public abstract class EntityCircle extends Entity {
|
||||||
|
|
||||||
// ---------- CONSTRUCTORs ----------
|
// ---------- CONSTRUCTORs ----------
|
||||||
|
|
||||||
/** Creates an {@link #Entity}.
|
/**
|
||||||
|
* Creates an {@link #Entity}.
|
||||||
|
*
|
||||||
* @param angle angle associated to the {@link #Entity}.
|
* @param angle angle associated to the {@link #Entity}.
|
||||||
* @param mass mass of the {@link #Entity}.
|
* @param mass mass of the {@link #Entity}.
|
||||||
* @param color color 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;
|
float theta = 360.0f / segments;
|
||||||
for (int i = 0; i < segments; i++) {
|
for (int i = 0; i < segments; i++) {
|
||||||
vertices[2 * i] = getX() + MathUtils.cosDeg(theta * (i + 1) + getRotation()) * radius;
|
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;
|
return vertices;
|
||||||
|
|
|
@ -8,7 +8,9 @@ public abstract class EntityQuad extends Entity {
|
||||||
|
|
||||||
// ---------- CONSTRUCTORs ----------
|
// ---------- CONSTRUCTORs ----------
|
||||||
|
|
||||||
/** Creates an {@link #Entity}.
|
/**
|
||||||
|
* Creates an {@link #Entity}.
|
||||||
|
*
|
||||||
* @param angle angle associated to the {@link #Entity}.
|
* @param angle angle associated to the {@link #Entity}.
|
||||||
* @param mass mass of the {@link #Entity}.
|
* @param mass mass of the {@link #Entity}.
|
||||||
* @param color color of the {@link #Entity}.
|
* @param color color of the {@link #Entity}.
|
||||||
|
|
|
@ -41,7 +41,8 @@ public class Moon extends Planet {
|
||||||
@Override
|
@Override
|
||||||
public void drawDebug(ShapeRenderer shapes) {
|
public void drawDebug(ShapeRenderer shapes) {
|
||||||
super.drawDebug(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());
|
shapes.line(getX(), getY(), sun.getX(), sun.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,19 +71,18 @@ public class Planet extends EntityCircle {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getInfo() {
|
protected String getInfo() {
|
||||||
return
|
return "radius=" + (int) radius + "\n" + "mass=" + (int) mass + "\n" + "pos=" + (int) getX()
|
||||||
"radius=" + (int)radius + "\n"
|
+ "," + (int) getY();
|
||||||
+ "mass=" + (int)mass + "\n"
|
|
||||||
+ "pos=" + (int)getX() + "," + (int)getY()
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
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,
|
batch.draw(backGround, getPosition().x - this.radius, getPosition().y - this.radius,
|
||||||
1, 1, getRotation(), 0, 0, texture.getWidth(), texture.getHeight(), false, false);
|
this.radius, this.radius, 2 * this.radius, 2 * this.radius, 1, 1, getRotation(), 0,
|
||||||
batch.draw(texture, getPosition().x - this.radius, getPosition().y - this.radius, this.radius, this.radius, 2 * this.radius, 2 * this.radius,
|
0, texture.getWidth(), texture.getHeight(), false, false);
|
||||||
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);
|
super.draw(batch, parentAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,8 @@ public class Player extends EntityQuad {
|
||||||
@Override
|
@Override
|
||||||
public void drawDebug(ShapeRenderer shapes) {
|
public void drawDebug(ShapeRenderer shapes) {
|
||||||
super.drawDebug(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());
|
shapes.line(home.getX(), home.getY(), getX(), getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +78,10 @@ public class Player extends EntityQuad {
|
||||||
T %= 100;
|
T %= 100;
|
||||||
int i = (int) (T * ((float) texture.size() / 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(),
|
batch.draw(texture.get(i), getPosition().x - getWidth() / 2,
|
||||||
1, 1, getRotation(), 0, 0, texture.get(i).getWidth(), texture.get(i).getHeight(), false, false);
|
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);
|
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));
|
setX(home.getX() + (home.getRadius() + getHeight() / 2)
|
||||||
setY(home.getY() + (home.getRadius() + getHeight()/2)*MathUtils.sinDeg(home.getRotation() + angle));
|
* MathUtils.cosDeg(home.getRotation() + angle));
|
||||||
|
setY(home.getY() + (home.getRadius() + getHeight() / 2)
|
||||||
|
* MathUtils.sinDeg(home.getRotation() + angle));
|
||||||
|
|
||||||
this.setRotation(home.getRotation() + angle - 90);
|
this.setRotation(home.getRotation() + angle - 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getInfo() {
|
protected String getInfo() {
|
||||||
return
|
return "pos=" + (int) getX() + "," + (int) getY();
|
||||||
"pos=" + (int)getX() + "," + (int)getY()
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,6 +120,7 @@ public class Player extends EntityQuad {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the active state of the {@link Player}.
|
* Change the active state of the {@link Player}.
|
||||||
|
*
|
||||||
* @param bool true or false
|
* @param bool true or false
|
||||||
*/
|
*/
|
||||||
public void setActive(boolean bool) {
|
public void setActive(boolean bool) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ public abstract class BaseScreen implements Screen {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void initialize();
|
public abstract void initialize();
|
||||||
|
|
||||||
public abstract void update(float dt);
|
public abstract void update(float dt);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,20 +44,30 @@ public abstract class BaseScreen implements Screen {
|
||||||
uiStage.draw();
|
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();
|
uiStage.dispose();
|
||||||
mainStage.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);
|
mainStage.getViewport().update(width, height, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void pause() {}
|
@Override
|
||||||
@Override public void resume() {}
|
public void pause() {}
|
||||||
@Override public void show() {}
|
|
||||||
@Override public void hide() {}
|
@Override
|
||||||
|
public void resume() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,7 +18,8 @@ public class CreditScreen extends BaseScreen {
|
||||||
if (!SagittariusGame.disableMusic) {
|
if (!SagittariusGame.disableMusic) {
|
||||||
|
|
||||||
SagittariusGame.music.stop();
|
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.setLooping(true);
|
||||||
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
||||||
SagittariusGame.music.play();
|
SagittariusGame.music.play();
|
||||||
|
|
|
@ -27,7 +27,8 @@ public class FPS extends Actor {
|
||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
super.draw(batch, 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() {
|
protected String getInfo() {
|
||||||
|
|
|
@ -51,7 +51,8 @@ public class GameScreen extends BaseScreen implements InputProcessor {
|
||||||
if (!SagittariusGame.disableMusic) {
|
if (!SagittariusGame.disableMusic) {
|
||||||
|
|
||||||
SagittariusGame.music.stop();
|
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.setLooping(true);
|
||||||
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
||||||
SagittariusGame.music.play();
|
SagittariusGame.music.play();
|
||||||
|
@ -124,7 +125,8 @@ public class GameScreen extends BaseScreen implements InputProcessor {
|
||||||
@Override
|
@Override
|
||||||
public void update(float dt) {
|
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));
|
unprojectedCursor = mainStage.getCamera().unproject(new Vector3(screenCursor, 0));
|
||||||
worldCursor = new Vector2(unprojectedCursor.x, unprojectedCursor.y);
|
worldCursor = new Vector2(unprojectedCursor.x, unprojectedCursor.y);
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,14 @@ public class MouseInfo extends Actor {
|
||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
super.draw(batch, 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() {
|
protected String getInfo() {
|
||||||
return
|
return "screen=" + (int) GameScreen.screenCursor.x + "," + (int) GameScreen.screenCursor.y
|
||||||
"screen=" + (int)GameScreen.screenCursor.x + "," + (int)GameScreen.screenCursor.y + "\n"
|
+ "\n" + "world=" + (int) GameScreen.worldCursor.x + ","
|
||||||
+ "world=" + (int)GameScreen.worldCursor.x + "," + (int)GameScreen.worldCursor.y
|
+ (int) GameScreen.worldCursor.y;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@ public class ResumeScreen extends BaseScreen {
|
||||||
|
|
||||||
if (!SagittariusGame.disableMusic) {
|
if (!SagittariusGame.disableMusic) {
|
||||||
SagittariusGame.music.stop();
|
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.setLooping(true);
|
||||||
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
||||||
SagittariusGame.music.play();
|
SagittariusGame.music.play();
|
||||||
|
@ -41,14 +42,16 @@ public class ResumeScreen extends BaseScreen {
|
||||||
disableMusic.setChecked(SagittariusGame.disableMusic);
|
disableMusic.setChecked(SagittariusGame.disableMusic);
|
||||||
|
|
||||||
// Change volume of the music
|
// 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
|
// disable sound checkbox
|
||||||
CheckBoxSounded disableSounds = new CheckBoxSounded("disable sounds");
|
CheckBoxSounded disableSounds = new CheckBoxSounded("disable sounds");
|
||||||
disableSounds.setChecked(SagittariusGame.disableSounds);
|
disableSounds.setChecked(SagittariusGame.disableSounds);
|
||||||
|
|
||||||
// Change volume of the sound
|
// 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
|
// save button
|
||||||
ButtonTextSounded applyButton = new ButtonTextSounded("Apply");
|
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) {
|
public void tap(InputEvent event, float x, float y, int count, int button) {
|
||||||
super.tap(event, x, y, count, button);
|
super.tap(event, x, y, count, button);
|
||||||
|
|
||||||
SagittariusGame.music.setVolume(Float.parseFloat(musicVolume.getTextField().getText()));
|
SagittariusGame.music
|
||||||
SagittariusGame.musicVolume = Float.parseFloat(musicVolume.getTextField().getText());
|
.setVolume(Float.parseFloat(musicVolume.getTextField().getText()));
|
||||||
SagittariusGame.soundsVolume = Float.parseFloat(musicSounds.getTextField().getText());
|
SagittariusGame.musicVolume =
|
||||||
|
Float.parseFloat(musicVolume.getTextField().getText());
|
||||||
|
SagittariusGame.soundsVolume =
|
||||||
|
Float.parseFloat(musicSounds.getTextField().getText());
|
||||||
|
|
||||||
// Deactivate music or not
|
// Deactivate music or not
|
||||||
if (disableMusic.isChecked() && SagittariusGame.music.isPlaying()) {
|
if (disableMusic.isChecked() && SagittariusGame.music.isPlaying()) {
|
||||||
SagittariusGame.music.stop();
|
SagittariusGame.music.stop();
|
||||||
SagittariusGame.disableMusic = true;
|
SagittariusGame.disableMusic = true;
|
||||||
}
|
} else if (!disableMusic.isChecked() && !SagittariusGame.music.isPlaying()) {
|
||||||
else if (!disableMusic.isChecked() && ! SagittariusGame.music.isPlaying()){
|
|
||||||
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
||||||
SagittariusGame.music.play();
|
SagittariusGame.music.play();
|
||||||
SagittariusGame.disableMusic = false;
|
SagittariusGame.disableMusic = false;
|
||||||
|
@ -93,7 +98,8 @@ public class ResumeScreen extends BaseScreen {
|
||||||
|
|
||||||
if (!SagittariusGame.disableMusic) {
|
if (!SagittariusGame.disableMusic) {
|
||||||
SagittariusGame.music.stop();
|
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.setLooping(true);
|
||||||
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
||||||
SagittariusGame.music.play();
|
SagittariusGame.music.play();
|
||||||
|
|
|
@ -23,7 +23,8 @@ public class SettingsScreen extends BaseScreen {
|
||||||
|
|
||||||
if (!SagittariusGame.disableMusic) {
|
if (!SagittariusGame.disableMusic) {
|
||||||
SagittariusGame.music.stop();
|
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.setLooping(true);
|
||||||
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
||||||
SagittariusGame.music.play();
|
SagittariusGame.music.play();
|
||||||
|
@ -37,7 +38,8 @@ public class SettingsScreen extends BaseScreen {
|
||||||
uiStage.addActor(table);
|
uiStage.addActor(table);
|
||||||
|
|
||||||
// G constant field
|
// 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
|
// dubug mode checkbox
|
||||||
CheckBoxSounded debugModeBox = new CheckBoxSounded("debug mode");
|
CheckBoxSounded debugModeBox = new CheckBoxSounded("debug mode");
|
||||||
|
@ -48,14 +50,16 @@ public class SettingsScreen extends BaseScreen {
|
||||||
disableMusic.setChecked(SagittariusGame.disableMusic);
|
disableMusic.setChecked(SagittariusGame.disableMusic);
|
||||||
|
|
||||||
// Change volume of the music
|
// 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
|
// disable sound checkbox
|
||||||
CheckBoxSounded disableSounds = new CheckBoxSounded("disable sounds");
|
CheckBoxSounded disableSounds = new CheckBoxSounded("disable sounds");
|
||||||
disableSounds.setChecked(SagittariusGame.disableSounds);
|
disableSounds.setChecked(SagittariusGame.disableSounds);
|
||||||
|
|
||||||
// Change volume of the sound
|
// 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
|
// go back button
|
||||||
ButtonTextSounded returnButton = new ButtonTextSounded("Go Back");
|
ButtonTextSounded returnButton = new ButtonTextSounded("Go Back");
|
||||||
|
@ -77,6 +81,7 @@ public class SettingsScreen extends BaseScreen {
|
||||||
|
|
||||||
shootArrow.addListener(new ClickListener() {
|
shootArrow.addListener(new ClickListener() {
|
||||||
private boolean capturing = false;
|
private boolean capturing = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||||
if (!shootArrow.isDisabled() && !capturing && button == Buttons.LEFT) {
|
if (!shootArrow.isDisabled() && !capturing && button == Buttons.LEFT) {
|
||||||
|
@ -110,23 +115,28 @@ public class SettingsScreen extends BaseScreen {
|
||||||
super.tap(event, x, y, count, button);
|
super.tap(event, x, y, count, button);
|
||||||
|
|
||||||
SagittariusGame.G = Float.parseFloat(gConstField.getTextField().getText());
|
SagittariusGame.G = Float.parseFloat(gConstField.getTextField().getText());
|
||||||
SagittariusGame.music.setVolume(Float.parseFloat(musicVolume.getTextField().getText()));
|
SagittariusGame.music
|
||||||
SagittariusGame.musicVolume= Float.parseFloat(musicVolume.getTextField().getText());
|
.setVolume(Float.parseFloat(musicVolume.getTextField().getText()));
|
||||||
SagittariusGame.soundsVolume = Float.parseFloat(musicSounds.getTextField().getText());
|
SagittariusGame.musicVolume =
|
||||||
|
Float.parseFloat(musicVolume.getTextField().getText());
|
||||||
|
SagittariusGame.soundsVolume =
|
||||||
|
Float.parseFloat(musicSounds.getTextField().getText());
|
||||||
SagittariusGame.debugMode = debugModeBox.isChecked();
|
SagittariusGame.debugMode = debugModeBox.isChecked();
|
||||||
|
|
||||||
SagittariusGame.moveLeftKey = Keys.valueOf(moveLeft.getText().toString());
|
SagittariusGame.moveLeftKey = Keys.valueOf(moveLeft.getText().toString());
|
||||||
SagittariusGame.moveRightKey = Keys.valueOf(moveRight.getText().toString());
|
SagittariusGame.moveRightKey = Keys.valueOf(moveRight.getText().toString());
|
||||||
SagittariusGame.zoomInKey = Keys.valueOf(zoomIn.getText().toString());
|
SagittariusGame.zoomInKey = Keys.valueOf(zoomIn.getText().toString());
|
||||||
SagittariusGame.zoomOutKey = Keys.valueOf(zoomOut.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
|
// Deactivate music or not
|
||||||
if (disableMusic.isChecked() && SagittariusGame.music.isPlaying()) {
|
if (disableMusic.isChecked() && SagittariusGame.music.isPlaying()) {
|
||||||
SagittariusGame.music.stop();
|
SagittariusGame.music.stop();
|
||||||
SagittariusGame.disableMusic = true;
|
SagittariusGame.disableMusic = true;
|
||||||
} else if (!disableMusic.isChecked() && !SagittariusGame.music.isPlaying()) {
|
} 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.setVolume(SagittariusGame.musicVolume);
|
||||||
SagittariusGame.music.play();
|
SagittariusGame.music.play();
|
||||||
SagittariusGame.disableMusic = false;
|
SagittariusGame.disableMusic = false;
|
||||||
|
|
|
@ -18,7 +18,8 @@ public class StartScreen extends BaseScreen {
|
||||||
if (!SagittariusGame.disableMusic) {
|
if (!SagittariusGame.disableMusic) {
|
||||||
if (SagittariusGame.music != null) {
|
if (SagittariusGame.music != null) {
|
||||||
SagittariusGame.music.stop();
|
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.setLooping(true);
|
||||||
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
||||||
SagittariusGame.music.play();
|
SagittariusGame.music.play();
|
||||||
|
@ -26,7 +27,8 @@ public class StartScreen extends BaseScreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
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.setLooping(true);
|
||||||
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
|
||||||
SagittariusGame.music.play();
|
SagittariusGame.music.play();
|
||||||
|
|
Loading…
Reference in a new issue