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
* generate random map (with parameters)
* move freely camera
* faire des textures (+ background)
* particules de flèche, quand un joueur meurt...
* faire le gestionnaire de keybinds
* faire des sons et musique
* astéroïdes
* bonus/gadgets
* améliorer trajectoires arrows en simulant tout n'univers

View file

@ -11,12 +11,12 @@ public class SagittariusGame extends Game {
// Constants
public static float G = 100;
public static boolean debugMode = true;
public static boolean debugMode = false;
public static Music music;
public static boolean disableMusic = false;
public static float musicVolume = 0.5f;
public static boolean disableMusic = true;
public static float musicVolume = 0.1f;
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 moveRightKey = Keys.RIGHT;
public static int zoomInKey = Keys.UP;

View file

@ -65,12 +65,13 @@ public class Bow extends Actor {
public void drawDebug(ShapeRenderer shapes) {
super.drawDebug(shapes);
if (pressed) {
if (power > 50)
if (power > 50) {
shapes.setColor(Color.RED);
shapes.line(this.anchor, GameScreen.worldCursor);
}
// shapes.line(this.anchor, GameScreen.worldCursor);
if (aimAssist) {
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);
}
}

View file

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

View file

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

View file

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