refactor!: reorganized packages,
everything is broken for now
This commit is contained in:
parent
2941bcef47
commit
3daea10663
|
@ -1,4 +1,4 @@
|
||||||
package sagittarius;
|
package sagittarius.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
class Arrow extends Entity {
|
public class Arrow extends Entity {
|
||||||
|
|
||||||
// ---------- ATTRIBUTEs ----------
|
// ---------- ATTRIBUTEs ----------
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class Arrow extends Entity {
|
||||||
private Vector2 acceleration = new Vector2();
|
private Vector2 acceleration = new Vector2();
|
||||||
private Vector2 force = new Vector2();
|
private Vector2 force = new Vector2();
|
||||||
|
|
||||||
protected float TTL = 20;
|
private float TTL = 20;
|
||||||
private final float length = 100;
|
private final float length = 100;
|
||||||
|
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
|
@ -86,7 +86,7 @@ class Arrow extends Entity {
|
||||||
*
|
*
|
||||||
* @param deltaTime time elapsed between 2 frames.
|
* @param deltaTime time elapsed between 2 frames.
|
||||||
*/
|
*/
|
||||||
void update(float deltaTime) {
|
public void update(float deltaTime) {
|
||||||
|
|
||||||
if (this.active) {
|
if (this.active) {
|
||||||
verifyActivity();
|
verifyActivity();
|
||||||
|
@ -121,12 +121,12 @@ class Arrow extends Entity {
|
||||||
|
|
||||||
// ---------- GRAPHICAL METHODs ----------
|
// ---------- GRAPHICAL METHODs ----------
|
||||||
|
|
||||||
void render(ShapeRenderer shapeRenderer) {
|
public void render(ShapeRenderer shapeRenderer) {
|
||||||
Vector2 tail = new Vector2(-this.length, 0).rotateDeg(this.angle).add(this.position);
|
Vector2 tail = new Vector2(-this.length, 0).rotateDeg(this.angle).add(this.position);
|
||||||
shapeRenderer.line(this.position, tail);
|
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 ?
|
// TODO : dirty, do it in an other way ?
|
||||||
if (active) {
|
if (active) {
|
|
@ -1,4 +1,4 @@
|
||||||
package sagittarius;
|
package sagittarius.model;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Buttons;
|
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.MathUtils;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
|
import sagittarius.SagittariusGame;
|
||||||
|
|
||||||
class Bow {
|
class Bow {
|
||||||
|
|
||||||
// ---------- ATTRIBUTEs ----------
|
// ---------- ATTRIBUTEs ----------
|
|
@ -1,4 +1,4 @@
|
||||||
package sagittarius;
|
package sagittarius.model;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
|
@ -1,16 +1,16 @@
|
||||||
package sagittarius;
|
package sagittarius.model;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
|
||||||
class Moon extends Planet {
|
public class Moon extends Planet {
|
||||||
|
|
||||||
private Planet planet;
|
private Planet planet;
|
||||||
private float altitude;
|
private float altitude;
|
||||||
|
|
||||||
// ---------- CONSTRUCTORs ----------
|
// ---------- 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);
|
super(planet.position, mass, radius);
|
||||||
this.planet = planet;
|
this.planet = planet;
|
||||||
this.altitude = altitude;
|
this.altitude = altitude;
|
|
@ -1,4 +1,4 @@
|
||||||
package sagittarius;
|
package sagittarius.model;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
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.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
class Planet extends Entity {
|
public class Planet extends Entity {
|
||||||
|
|
||||||
// ---------- ATTRIBUTEs ----------
|
// ---------- ATTRIBUTEs ----------
|
||||||
|
|
||||||
|
@ -14,12 +14,12 @@ class Planet extends Entity {
|
||||||
|
|
||||||
// ---------- CONSTRUCTORs ----------
|
// ---------- CONSTRUCTORs ----------
|
||||||
|
|
||||||
Planet(Vector2 position, float mass, float radius) {
|
public Planet(Vector2 position, float mass, float radius) {
|
||||||
super(position, mass);
|
super(position, mass);
|
||||||
this.radius = radius;
|
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(position, mass, radius);
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package sagittarius;
|
package sagittarius.model;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Keys;
|
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.MathUtils;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
class Player extends Entity {
|
public class Player extends Entity {
|
||||||
|
|
||||||
// ---------- ATTRIBUTEs ----------
|
// ---------- ATTRIBUTEs ----------
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class Player extends Entity {
|
||||||
|
|
||||||
// ---------- CONSTRUCTORs ----------
|
// ---------- CONSTRUCTORs ----------
|
||||||
|
|
||||||
Player(Planet home) {
|
public Player(Planet home) {
|
||||||
super(home.position, 1);
|
super(home.position, 1);
|
||||||
this.home = home;
|
this.home = home;
|
||||||
this.bow = new Bow(this, true);
|
this.bow = new Bow(this, true);
|
|
@ -1,4 +1,4 @@
|
||||||
package sagittarius;
|
package sagittarius.view;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.ScreenAdapter;
|
import com.badlogic.gdx.ScreenAdapter;
|
||||||
|
@ -26,7 +26,7 @@ class GameScreen extends ScreenAdapter {
|
||||||
private BitmapFont font;
|
private BitmapFont font;
|
||||||
|
|
||||||
// camera stuff
|
// camera stuff
|
||||||
private Viewport viewport; // TODO : useless ?
|
static Viewport viewport; // TODO : useless ?
|
||||||
protected static Camera camera;
|
protected static Camera camera;
|
||||||
|
|
||||||
// TODO: categorize better ?
|
// TODO: categorize better ?
|
||||||
|
@ -54,7 +54,8 @@ class GameScreen extends ScreenAdapter {
|
||||||
clearScreen();
|
clearScreen();
|
||||||
|
|
||||||
// ---------- batch ----------
|
// ---------- batch ----------
|
||||||
batch.setProjectionMatrix(camera.combined);
|
batch.setProjectionMatrix(camera.projection);
|
||||||
|
batch.setTransformMatrix(camera.view);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
|
|
||||||
// planets
|
// planets
|
|
@ -1,6 +1,5 @@
|
||||||
package sagittarius;
|
package sagittarius.view;
|
||||||
|
|
||||||
import com.badlogic.gdx.Game;
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
|
@ -23,14 +22,19 @@ class HUD implements Disposable {
|
||||||
}
|
}
|
||||||
|
|
||||||
void render() {
|
void render() {
|
||||||
|
batch.setProjectionMatrix(GameScreen.camera.projection);
|
||||||
|
batch.setTransformMatrix(GameScreen.camera.view);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
|
|
||||||
// framerate
|
// 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,
|
||||||
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);
|
// GameScreen.viewport.getWorldWidth() + 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);
|
// 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();
|
batch.end();
|
||||||
}
|
}
|
Loading…
Reference in a new issue