fix: small arrow trajectory in non debug mode

fix: broken music
This commit is contained in:
Laureηt 2021-05-27 16:11:14 +02:00
parent 52cc2c5117
commit 0ef20fb8d2
6 changed files with 32 additions and 36 deletions

View file

@ -30,10 +30,7 @@ The resulting .jar file should be in `desktop/build/libs/`
## TODO LIST ## TODO LIST
* generate random map (with parameters) * generate random map (with parameters)
* move freely camera * move freely camera
* faire des textures (+ background)
* particules de flèche, quand un joueur meurt... * particules de flèche, quand un joueur meurt...
* faire le gestionnaire de keybinds
* faire des sons et musique
* astéroïdes * astéroïdes
* bonus/gadgets * bonus/gadgets
* améliorer trajectoires arrows en simulant tout n'univers * améliorer trajectoires arrows en simulant tout n'univers

View file

@ -11,12 +11,12 @@ public class SagittariusGame extends Game {
// Constants // Constants
public static float G = 100; public static float G = 100;
public static boolean debugMode = true; public static boolean debugMode = false;
public static Music music; public static Music music;
public static boolean disableMusic = false; public static boolean disableMusic = true;
public static float musicVolume = 0.5f; public static float musicVolume = 0.1f;
public static boolean disableSounds = false; public static boolean disableSounds = false;
public static float soundsVolume = 0.5f; public static float soundsVolume = 0.1f;
public static int moveLeftKey = Keys.LEFT; public static int moveLeftKey = Keys.LEFT;
public static int moveRightKey = Keys.RIGHT; public static int moveRightKey = Keys.RIGHT;
public static int zoomInKey = Keys.UP; public static int zoomInKey = Keys.UP;

View file

@ -65,12 +65,13 @@ 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) if (power > 50) {
shapes.setColor(Color.RED); shapes.setColor(Color.RED);
shapes.line(this.anchor, GameScreen.worldCursor); }
// shapes.line(this.anchor, GameScreen.worldCursor);
if (aimAssist) { if (aimAssist) {
Trajectory traj = Trajectory traj =
Arrow.computeTrajectory(angle, power, GameScreen.playerCurrent, 250, 0.03f); Arrow.computeTrajectory(angle, power, GameScreen.playerCurrent, 50, 0.01f);
shapes.polyline(traj.path, 0, traj.actualSize); shapes.polyline(traj.path, 0, traj.actualSize);
} }
} }

View file

@ -4,8 +4,6 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL30; import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
import sagittarius.SagittariusGame;
import com.badlogic.gdx.Screen; import com.badlogic.gdx.Screen;
public abstract class BaseScreen implements Screen { public abstract class BaseScreen implements Screen {
@ -46,16 +44,13 @@ public abstract class BaseScreen implements Screen {
@Override @Override
public void dispose() { public void dispose() {
SagittariusGame.music =
Gdx.audio.newMusic(Gdx.files.internal("sounds/Ghostrifter-Deflector.mp3"));
uiStage.dispose(); uiStage.dispose();
mainStage.dispose(); mainStage.dispose();
} }
@Override @Override
public void resize(int width, int height) { public void resize(int width, int height) {
mainStage.getViewport().update(width, height, true); mainStage.getViewport().update(width, height, false);
} }
@Override @Override

View file

@ -48,19 +48,23 @@ public class GameScreen extends BaseScreen implements InputProcessor {
@Override @Override
public void initialize() { public void initialize() {
if (!SagittariusGame.disableMusic) { if (SagittariusGame.music != null) {
SagittariusGame.music.stop(); SagittariusGame.music.stop();
SagittariusGame.music = } SagittariusGame.music =
Gdx.audio.newMusic(Gdx.files.internal("sounds/music/game_music.mp3")); 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);
if (!SagittariusGame.disableMusic) {
SagittariusGame.music.play(); SagittariusGame.music.play();
} }
Gdx.input.setInputProcessor(this); Gdx.input.setInputProcessor(this);
// The one and only Bow
Bow bow = new Bow(true);
bow.setDebug(true);
mainStage.addActor(bow);
// arrows // arrows
arrows = new Group(); arrows = new Group();
mainStage.addActor(arrows); mainStage.addActor(arrows);
@ -96,10 +100,6 @@ public class GameScreen extends BaseScreen implements InputProcessor {
mainStage.addActor(players); mainStage.addActor(players);
// The one and only Bow
Bow bow = new Bow(true);
mainStage.addActor(bow);
// others // others
FPS fpsCounter = new FPS(uiStage); FPS fpsCounter = new FPS(uiStage);
uiStage.addActor(fpsCounter); uiStage.addActor(fpsCounter);
@ -125,8 +125,7 @@ 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 screenCursor = new Vector2(Gdx.input.getX(), Gdx.input.getY());
// 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);

View file

@ -21,12 +21,14 @@ public class SettingsScreen extends BaseScreen {
@Override @Override
public void initialize() { public void initialize() {
if (!SagittariusGame.disableMusic) { if (SagittariusGame.music != null) {
SagittariusGame.music.stop(); SagittariusGame.music.stop();
SagittariusGame.music = }
Gdx.audio.newMusic(Gdx.files.internal("sounds/music/resumeMenu_music.mp3")); SagittariusGame.music =
SagittariusGame.music.setLooping(true); Gdx.audio.newMusic(Gdx.files.internal("sounds/music/resumeMenu_music.mp3"));
SagittariusGame.music.setVolume(SagittariusGame.musicVolume); SagittariusGame.music.setLooping(true);
SagittariusGame.music.setVolume(SagittariusGame.musicVolume);
if (!SagittariusGame.disableMusic) {
SagittariusGame.music.play(); SagittariusGame.music.play();
} }
@ -72,7 +74,8 @@ public class SettingsScreen extends BaseScreen {
}); });
// Control buttons // Control buttons
VisTextButton shootArrow = new VisTextButton(String.valueOf(SagittariusGame.shootArrowButton));; VisTextButton shootArrow =
new VisTextButton(String.valueOf(SagittariusGame.shootArrowButton));;
VisTextButton moveLeft = new VisTextButton(Keys.toString(SagittariusGame.moveLeftKey)); VisTextButton moveLeft = new VisTextButton(Keys.toString(SagittariusGame.moveLeftKey));
VisTextButton moveRight = new VisTextButton(Keys.toString(SagittariusGame.moveRightKey)); VisTextButton moveRight = new VisTextButton(Keys.toString(SagittariusGame.moveRightKey));
VisTextButton zoomIn = new VisTextButton(Keys.toString(SagittariusGame.zoomInKey)); VisTextButton zoomIn = new VisTextButton(Keys.toString(SagittariusGame.zoomInKey));
@ -127,7 +130,8 @@ public class SettingsScreen extends BaseScreen {
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 = Integer.parseInt(shootArrow.getText().toString()); SagittariusGame.shootArrowButton =
Integer.parseInt(shootArrow.getText().toString());
// 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();