chore: added some javadoc
This commit is contained in:
parent
6363a6f1c5
commit
ea2575b89c
|
@ -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
|
||||
[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
|
|
@ -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<Float> path = new ArrayList<Float>();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -31,6 +31,9 @@ class Moon extends Planet {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Planet which the Moon orbits.
|
||||
*/
|
||||
Planet getPlanet() {
|
||||
return this.planet;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue