diff --git a/README.md b/README.md index 2c0c073..83c5648 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ A turn based game in wich players kill each others using bows, arrows and GRAVITY ! ## Built with +* [openJDK 15](https://openjdk.java.net/projects/jdk/15/) * [libGDX](https://libgdx.com/) ## Usage @@ -19,7 +20,7 @@ To export the game to a .jar file: ```bash ./gradlew desktop:dist ``` -The resulting .jar files should be in `desktop/build/libs/` +The resulting .jar files should be in `*/build/libs/` ## TODO LIST @@ -43,5 +44,5 @@ Distributed under the [MIT](https://choosealicense.com/licenses/mit/) License. S -[license-shield]: https://img.shields.io/github/license/othneildrew/Best-README-Template.svg?style=for-the-badge -[license-url]: https://github.com/othneildrew/Best-README-Template/blob/master/LICENSE.txt \ No newline at end of file +[license-shield]: https://img.shields.io/badge/LICENSE-MIT-green?style=for-the-badge +[license-url]: https://git.inpt.fr/tobgang/sagittarius/-/blob/master/LICENSE \ No newline at end of file diff --git a/core/src/sagittarius/Arrow.java b/core/src/sagittarius/Arrow.java index 86c36d8..40b29b5 100644 --- a/core/src/sagittarius/Arrow.java +++ b/core/src/sagittarius/Arrow.java @@ -43,6 +43,7 @@ class Arrow extends Entity { /** * Computes the {@link Arrow#force} exerted on the Arrow, * according to the other weighted entities. + * @return the complete force exerted on the Arrow. */ private Vector2 computeForce() { Vector2 force = new Vector2(); @@ -146,6 +147,7 @@ class Arrow extends Entity { * * @param iterations number of iterations for the integration. * @param timeStep time period used for the integration. + * @return an array of vertices describing the trajectory of the Arrow. */ static float[] traj(float angle, float power, Player shooter, int iterations, float timeStep) { ArrayList path = new ArrayList(); diff --git a/core/src/sagittarius/Bow.java b/core/src/sagittarius/Bow.java index 2df382c..570ae8c 100644 --- a/core/src/sagittarius/Bow.java +++ b/core/src/sagittarius/Bow.java @@ -28,7 +28,13 @@ class Bow { } // ---------- METHODs ---------- - + + /** + * Updates the physical attributes of the Bow, + * wich are later used to generate an Arrow. + * + * @param deltaTime time elapsed between 2 frames. + */ void update(double deltaTime) { if (Gdx.input.isButtonJustPressed(Buttons.LEFT) && !pressed) { @@ -43,10 +49,19 @@ class Bow { } + /** + * Generates an Arrow according to the Bow's attributes. + * + * @return an Arrow. + */ private Arrow getArrow() { return new Arrow(angle, power, shooter); } + /** + * Converts the Bow's attributes to apply it + * to the Arrow's constructor. + */ private void computeArrow() { aim = this.anchor.cpy().sub(SagittariusGame.worldCursor); angle = aim.angleDeg(); @@ -56,9 +71,11 @@ class Bow { void render(ShapeRenderer shapeRenderer) { if (pressed) { shapeRenderer.line(this.anchor, SagittariusGame.worldCursor); - float[] traj = Arrow.traj(angle, power, shooter, 400, 0.05f); - if (traj.length > 2) { - shapeRenderer.polyline(traj); + if (aimAssist) { + float[] traj = Arrow.traj(angle, power, shooter, 400, 0.05f); + if (traj.length > 2) { + shapeRenderer.polyline(traj); + } } } } diff --git a/core/src/sagittarius/Entity.java b/core/src/sagittarius/Entity.java index b32cd8d..7a02771 100644 --- a/core/src/sagittarius/Entity.java +++ b/core/src/sagittarius/Entity.java @@ -25,9 +25,10 @@ abstract class Entity { // ---------- METHODs ---------- /** - * Return the euclidian distance to another entity - * @param entity - * @return distance to entity + * Returns the euclidian distance to another entity. + * + * @param entity the other Entity whose distance we wish to evaluate. + * @return distance to Entity. */ float distanceTo(Entity entity) { return this.position.cpy().sub(entity.position).len(); diff --git a/core/src/sagittarius/Moon.java b/core/src/sagittarius/Moon.java index d371d2e..c81b84c 100644 --- a/core/src/sagittarius/Moon.java +++ b/core/src/sagittarius/Moon.java @@ -31,6 +31,9 @@ class Moon extends Planet { } + /** + * @return the Planet which the Moon orbits. + */ Planet getPlanet() { return this.planet; } diff --git a/core/src/sagittarius/Planet.java b/core/src/sagittarius/Planet.java index 78ab2ca..8a1c0e1 100644 --- a/core/src/sagittarius/Planet.java +++ b/core/src/sagittarius/Planet.java @@ -36,6 +36,9 @@ class Planet extends Entity { font.draw(batch, "x = " + (int) position.x + ", y = " + (int) position.y, position.x, position.y); } + /** + * @return the radius of the Planet. + */ float getRadius() { return this.radius; } diff --git a/core/src/sagittarius/Player.java b/core/src/sagittarius/Player.java index b1acb29..1105252 100644 --- a/core/src/sagittarius/Player.java +++ b/core/src/sagittarius/Player.java @@ -24,7 +24,7 @@ class Player extends Entity { Player(Planet home) { super(home.position, 1); this.home = home; - this.bow = new Bow(this, false); + this.bow = new Bow(this, true); this.angle = 45; // TODO : tmp } @@ -40,6 +40,12 @@ class Player extends Entity { font.draw(batch, "x = " + (int) position.x + ", y = " + (int) position.y, position.x, position.y); } + /** + * Updates the attributes of the Player, + * must be called in the main update loop. + * + * @param deltaTime time elapsed between 2 frames. + */ void update(float deltaTime) { // TODO : do eventListening instead of polling @@ -57,6 +63,9 @@ class Player extends Entity { } + /** + * Computes the position of the Player according to its attributes. + */ void computePosition() { Vector2 homePosition = this.home.position; float homeRadius = this.home.getRadius(); @@ -66,6 +75,9 @@ class Player extends Entity { this.positionBottom.y = homePosition.y + homeRadius*MathUtils.sinDeg(angle); } + /** + * @return the Player's home Planet. + */ Planet getHome() { return this.home; }