refactor!: reorganized packages,

everything is broken for now
This commit is contained in:
Laureηt 2021-04-08 21:34:17 +02:00
parent 2941bcef47
commit 3daea10663
8 changed files with 34 additions and 27 deletions

View file

@ -1,4 +1,4 @@
package sagittarius;
package sagittarius.model;
import java.util.ArrayList;
@ -7,7 +7,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Vector2;
class Arrow extends Entity {
public class Arrow extends Entity {
// ---------- ATTRIBUTEs ----------
@ -15,7 +15,7 @@ class Arrow extends Entity {
private Vector2 acceleration = new Vector2();
private Vector2 force = new Vector2();
protected float TTL = 20;
private float TTL = 20;
private final float length = 100;
private boolean active = true;
@ -86,7 +86,7 @@ class Arrow extends Entity {
*
* @param deltaTime time elapsed between 2 frames.
*/
void update(float deltaTime) {
public void update(float deltaTime) {
if (this.active) {
verifyActivity();
@ -121,12 +121,12 @@ class Arrow extends Entity {
// ---------- GRAPHICAL METHODs ----------
void render(ShapeRenderer shapeRenderer) {
public void render(ShapeRenderer shapeRenderer) {
Vector2 tail = new Vector2(-this.length, 0).rotateDeg(this.angle).add(this.position);
shapeRenderer.line(this.position, tail);
}
void renderDebug(Batch batch, BitmapFont font) {
public void renderDebug(Batch batch, BitmapFont font) {
// TODO : dirty, do it in an other way ?
if (active) {

View file

@ -1,4 +1,4 @@
package sagittarius;
package sagittarius.model;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Buttons;
@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import sagittarius.SagittariusGame;
class Bow {
// ---------- ATTRIBUTEs ----------

View file

@ -1,4 +1,4 @@
package sagittarius;
package sagittarius.model;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;

View file

@ -1,16 +1,16 @@
package sagittarius;
package sagittarius.model;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.MathUtils;
class Moon extends Planet {
public class Moon extends Planet {
private Planet planet;
private float altitude;
// ---------- CONSTRUCTORs ----------
Moon(Planet planet, float mass, float radius, float altitude) {
public Moon(Planet planet, float mass, float radius, float altitude) {
super(planet.position, mass, radius);
this.planet = planet;
this.altitude = altitude;

View file

@ -1,4 +1,4 @@
package sagittarius;
package sagittarius.model;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Vector2;
class Planet extends Entity {
public class Planet extends Entity {
// ---------- ATTRIBUTEs ----------
@ -14,12 +14,12 @@ class Planet extends Entity {
// ---------- CONSTRUCTORs ----------
Planet(Vector2 position, float mass, float radius) {
public Planet(Vector2 position, float mass, float radius) {
super(position, mass);
this.radius = radius;
}
Planet(Vector2 position, float mass, float radius, Color color) {
public Planet(Vector2 position, float mass, float radius, Color color) {
this(position, mass, radius);
this.color = color;
}

View file

@ -1,4 +1,4 @@
package sagittarius;
package sagittarius.model;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
@ -8,7 +8,7 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
class Player extends Entity {
public class Player extends Entity {
// ---------- ATTRIBUTEs ----------
@ -21,7 +21,7 @@ class Player extends Entity {
// ---------- CONSTRUCTORs ----------
Player(Planet home) {
public Player(Planet home) {
super(home.position, 1);
this.home = home;
this.bow = new Bow(this, true);

View file

@ -1,4 +1,4 @@
package sagittarius;
package sagittarius.view;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
@ -26,7 +26,7 @@ class GameScreen extends ScreenAdapter {
private BitmapFont font;
// camera stuff
private Viewport viewport; // TODO : useless ?
static Viewport viewport; // TODO : useless ?
protected static Camera camera;
// TODO: categorize better ?
@ -54,7 +54,8 @@ class GameScreen extends ScreenAdapter {
clearScreen();
// ---------- batch ----------
batch.setProjectionMatrix(camera.combined);
batch.setProjectionMatrix(camera.projection);
batch.setTransformMatrix(camera.view);
batch.begin();
// planets

View file

@ -1,6 +1,5 @@
package sagittarius;
package sagittarius.view;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
@ -23,14 +22,19 @@ class HUD implements Disposable {
}
void render() {
batch.setProjectionMatrix(GameScreen.camera.projection);
batch.setTransformMatrix(GameScreen.camera.view);
batch.begin();
// framerate
font.draw(batch, frameRate + " fps", 3, Gdx.graphics.getHeight() - 3);
font.draw(batch, frameRate + " fps", 3, GameScreen.viewport.getWorldHeight() - 3);
// cursor positions, oui c'est dégueu
font.draw(batch, "x_r = " + (int) SagittariusGame.screenCursor.x + ", y_r = " + (int) SagittariusGame.screenCursor.y, SagittariusGame.screenCursor.x + 5, Gdx.graphics.getHeight() - SagittariusGame.screenCursor.y + 5);
font.draw(batch, "x_g = " + (int) SagittariusGame.worldCursor.x + ", y_g = " + (int) SagittariusGame.worldCursor.y, SagittariusGame.screenCursor.x + 5, Gdx.graphics.getHeight() - SagittariusGame.screenCursor.y + 20);
// font.draw(batch, "x_r = " + (int) SagittariusGame.screenCursor.x + ", y_r = " + (int) SagittariusGame.screenCursor.y,
// GameScreen.viewport.getWorldWidth() + 5,
// GameScreen.viewport.getWorldHeight() + 5);
// font.draw(batch, "x_g = " + (int) SagittariusGame.worldCursor.x + ", y_g = " + (int) SagittariusGame.worldCursor.y,
// GameScreen.viewport.getWorldWidth() + 5,
// GameScreen.viewport.getWorldHeight() + 20);
batch.end();
}