diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e2c608d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,12 @@
+# TODO-list
+
+0. do a better README
+1. player turn
+2. kill player
+3. move freely camera
+4. lerp camera arrow
+5. event based shit
+6. menus test
+7. améliorer trajectoires arrows en simulant tout n'univers
+8. rotating planets and moons (on themselves)
+9. faire des sous-packages, sgittarius.modele, sagittarius.view, saggitarius.control ...
\ No newline at end of file
diff --git a/core/src/sagittarius/Arrow.java b/core/src/sagittarius/Arrow.java
index 8b8a867..86c36d8 100644
--- a/core/src/sagittarius/Arrow.java
+++ b/core/src/sagittarius/Arrow.java
@@ -14,8 +14,8 @@ class Arrow extends Entity {
private Vector2 velocity = new Vector2();
private Vector2 acceleration = new Vector2();
private Vector2 force = new Vector2();
-
- float TTL = 20;
+
+ protected float TTL = 20;
private final float length = 100;
private boolean active = true;
@@ -24,6 +24,13 @@ class Arrow extends Entity {
// ---------- CONSTRUCTORs ----------
+ /**
+ * Constructs an Arrow using its initial conditions.
+ *
+ * @param angle initial angle of the Arrow (in degrees).
+ * @param power power given to the Arrow a Bow.
+ * @param shooter Bow's shooter.
+ */
Arrow(float angle, float power, Player shooter) {
super(shooter.position, 1);
this.velocity = new Vector2(power, 0).setAngleDeg(angle);
@@ -32,7 +39,11 @@ class Arrow extends Entity {
}
// ---------- METHODs ----------
-
+
+ /**
+ * Computes the {@link Arrow#force} exerted on the Arrow,
+ * according to the other weighted entities.
+ */
private Vector2 computeForce() {
Vector2 force = new Vector2();
for (Planet attractor : SagittariusGame.planetList) {
@@ -48,6 +59,9 @@ class Arrow extends Entity {
return force;
}
+ /**
+ * Verify whether or not the Arrow contacts an Entity.
+ */
private void verifyActivity() {
for (Planet planet : SagittariusGame.planetList) {
if (this.distanceTo(planet) < planet.getRadius()) {
@@ -65,6 +79,12 @@ class Arrow extends Entity {
}
}
+ /**
+ * Updates the physical attributes of the Arrow,
+ * must be called in the main update loop.
+ *
+ * @param deltaTime time elapsed between 2 frames.
+ */
void update(float deltaTime) {
if (this.active) {
@@ -77,9 +97,15 @@ class Arrow extends Entity {
}
}
+ /**
+ * Computes the next position of the Arrow
+ * according to its physical attributes
+ * using the Verlet integration scheme.
+ *
+ * @param deltaTime time difference used in the integration.
+ * @see https://gamedev.stackexchange.com/a/41917.
+ */
private void integrationVerlet(float deltaTime) {
- // Verlet integration
- // https://gamedev.stackexchange.com/questions/15708/how-can-i-implement-gravity/41917#41917
this.acceleration = this.force.cpy();
@@ -92,6 +118,8 @@ class Arrow extends Entity {
this.velocity.y += deltaTime * ( this.acceleration.y + this.force.y ) / 2;
}
+// ---------- GRAPHICAL METHODs ----------
+
void render(ShapeRenderer shapeRenderer) {
Vector2 tail = new Vector2(-this.length, 0).rotateDeg(this.angle).add(this.position);
shapeRenderer.line(this.position, tail);
@@ -99,7 +127,7 @@ class Arrow extends Entity {
void renderDebug(Batch batch, BitmapFont font) {
- // TODO : dirty, do it in an other way
+ // TODO : dirty, do it in an other way ?
if (active) {
font.draw(batch, "TTL = " + this.TTL, this.position.x, this.position.y + font.getCapHeight()*5);
font.draw(batch, "pos = " + this.position, this.position.x, this.position.y + font.getCapHeight()*4);
@@ -112,6 +140,13 @@ class Arrow extends Entity {
// ---------- STATIC METHODs ----------
+ /** // TODO : pass directly an Arrow instead of 3 arguments
+ * Computes the trajectory of an Arrow,
+ * given its initial conditions.
+ *
+ * @param iterations number of iterations for the integration.
+ * @param timeStep time period used for the integration.
+ */
static float[] traj(float angle, float power, Player shooter, int iterations, float timeStep) {
ArrayList path = new ArrayList();
Arrow dummyArrow = new Arrow(angle, power, shooter);
@@ -124,6 +159,7 @@ class Arrow extends Entity {
}
// TODO : optimize, lots of useless stuff + change name
+ // or ignore and use adapters
final float[] arr = new float[path.size()];
int index = 0;
diff --git a/core/src/sagittarius/Bow.java b/core/src/sagittarius/Bow.java
index f704e92..2df382c 100644
--- a/core/src/sagittarius/Bow.java
+++ b/core/src/sagittarius/Bow.java
@@ -17,7 +17,7 @@ class Bow {
private Vector2 anchor;
private Vector2 aim;
-
+
private float power;
// ---------- CONSTRUCTORs ----------
diff --git a/core/src/sagittarius/Entity.java b/core/src/sagittarius/Entity.java
index 09cac56..b32cd8d 100644
--- a/core/src/sagittarius/Entity.java
+++ b/core/src/sagittarius/Entity.java
@@ -4,11 +4,11 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
abstract class Entity {
-
+
// ---------- ATTRIBUTs ----------
protected Vector2 position;
-
+
protected float mass = 1.0f;
protected float angle;
protected Color color = Color.WHITE;
diff --git a/core/src/sagittarius/GameScreen.java b/core/src/sagittarius/GameScreen.java
index ce93f92..a6fd612 100644
--- a/core/src/sagittarius/GameScreen.java
+++ b/core/src/sagittarius/GameScreen.java
@@ -26,7 +26,7 @@ class GameScreen extends ScreenAdapter {
private BitmapFont font;
// camera stuff
- private Viewport viewport;
+ private Viewport viewport; // TODO : useless ?
protected static Camera camera;
// TODO: categorize better ?
@@ -66,7 +66,7 @@ class GameScreen extends ScreenAdapter {
for (Moon moon : SagittariusGame.moonList) {
moon.renderDebug(batch, font);
}
-
+
// players
for (Player player : SagittariusGame.playerList) {
player.renderDebug(batch, font);
@@ -132,6 +132,7 @@ class GameScreen extends ScreenAdapter {
camera.update();
batch.setProjectionMatrix(camera.combined);
shapeRenderer.setProjectionMatrix(camera.combined);
+ hud.resize();
}
@Override
diff --git a/core/src/sagittarius/HUD.java b/core/src/sagittarius/HUD.java
index a99ed1e..0587361 100644
--- a/core/src/sagittarius/HUD.java
+++ b/core/src/sagittarius/HUD.java
@@ -1,5 +1,6 @@
package sagittarius;
+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 +24,14 @@ class HUD implements Disposable {
void render() {
batch.begin();
-
+
// framerate
font.draw(batch, frameRate + " fps", 3, Gdx.graphics.getHeight() - 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);
-
+
batch.end();
}
@@ -40,4 +41,8 @@ class HUD implements Disposable {
font.dispose();
}
+ public void resize() {
+ // TODO
+ }
+
}
diff --git a/core/src/sagittarius/Planet.java b/core/src/sagittarius/Planet.java
index aad98bb..78ab2ca 100644
--- a/core/src/sagittarius/Planet.java
+++ b/core/src/sagittarius/Planet.java
@@ -9,7 +9,7 @@ import com.badlogic.gdx.math.Vector2;
class Planet extends Entity {
// ---------- ATTRIBUTEs ----------
-
+
private float radius = 10;
// ---------- CONSTRUCTORs ----------
@@ -21,7 +21,7 @@ class Planet extends Entity {
Planet(Vector2 position, float mass, float radius, Color color) {
this(position, mass, radius);
- this.color = color;
+ this.color = color;
}
// ---------- METHODs ----------
@@ -32,6 +32,7 @@ class Planet extends Entity {
}
void renderDebug(Batch batch, BitmapFont font) {
+ font.draw(batch, "mass = " + mass, position.x, position.y + 15);
font.draw(batch, "x = " + (int) position.x + ", y = " + (int) position.y, position.x, position.y);
}
diff --git a/core/src/sagittarius/Player.java b/core/src/sagittarius/Player.java
index ad2500a..b1acb29 100644
--- a/core/src/sagittarius/Player.java
+++ b/core/src/sagittarius/Player.java
@@ -27,7 +27,7 @@ class Player extends Entity {
this.bow = new Bow(this, false);
this.angle = 45; // TODO : tmp
}
-
+
// ---------- METHODs ----------
void render(ShapeRenderer shapeRenderer) {
diff --git a/core/src/sagittarius/SagittariusGame.java b/core/src/sagittarius/SagittariusGame.java
index 7f7e557..93ae273 100644
--- a/core/src/sagittarius/SagittariusGame.java
+++ b/core/src/sagittarius/SagittariusGame.java
@@ -25,26 +25,32 @@ public class SagittariusGame extends Game {
static ArrayList moonList;
static ArrayList playerList;
static ArrayList arrowList;
-
+ // TODO : fix this shit, too many for loops
+
// ---------- METHODs ----------
@Override
public void create() {
setScreen(new GameScreen());
-
+
planetList = new ArrayList();
planetList.add( new Planet(new Vector2(400, 400), 1000, 50) );
- planetList.add( new Planet(new Vector2(1000, 400), 1000, 100, Color.CYAN) );
+ planetList.add( new Planet(new Vector2(1400, 700), 1000, 100, Color.CYAN) );
moonList = new ArrayList();
moonList.add( new Moon(planetList.get(1), 100, 20, 300) );
playerList = new ArrayList();
playerList.add( new Player(planetList.get(0)) );
-
+
arrowList = new ArrayList();
}
+ /**
+ * Main update loop.
+ *
+ * @param deltaTime time elapsed between 2 frames.
+ */
static void update(float deltaTime) {
// cursors
@@ -70,7 +76,7 @@ public class SagittariusGame extends Game {
it.remove();
}
}
-
+
}
}