Skip to content

Commit

Permalink
Added JavaDoc tags
Browse files Browse the repository at this point in the history
- Added author, since, and updated tags to javadoc
  • Loading branch information
uoy-jb2501 committed Apr 28, 2022
1 parent 428b5c9 commit b65d1cf
Show file tree
Hide file tree
Showing 36 changed files with 222 additions and 17 deletions.
1 change: 1 addition & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ javadoc {
source = sourceSets.main.allJava
classpath = sourceSets.main.runtimeClasspath
title = "ShardSoftware Mario Pirate Game"
options.tags = [ "tt.updated:a:'Updated:'" ]
}

check.dependsOn jacocoTestReport
7 changes: 5 additions & 2 deletions core/src/main/java/io/github/annabeths/Boats/AIBoat.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import io.github.annabeths.GameScreens.GameController;
import io.github.annabeths.Level.GameMap;

/**
* @since Assessment 2
*/
public abstract class AIBoat extends Boat {

/** The current state of the AI */
Expand All @@ -15,7 +18,7 @@ public abstract class AIBoat extends Boat {
Vector2 initialPosition;
Vector2 destination;
public float plunderValue;
public float xpValue;
public float xpValue;

/** How close should the boat be to its destination before setting a new one */
float destinationThreshold = 50f;
Expand Down Expand Up @@ -161,5 +164,5 @@ public float getDestinationThreshold() {
return destinationThreshold;
}

abstract void Shoot();
abstract void Shoot();
}
15 changes: 7 additions & 8 deletions core/src/main/java/io/github/annabeths/Boats/AttackBoat.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/**
* A form of {@link AIBoat} that can attack other ships
*
* @since Assessment 2
* @author James Burnell
*/
public abstract class AttackBoat extends AIBoat {
Expand Down Expand Up @@ -74,28 +75,26 @@ public void updateAIState() {

@Override
public void Update(float delta) {
if (isDead())
Destroy();
if (isDead()) Destroy();
timeSinceLastShot += delta;

updateAIState();

switch (state) {
case APPROACH :
case APPROACH:
approach(delta);
break;
case ATTACK :
case ATTACK:
attack(delta);
break;
case IDLE :
case IDLE:
idle(delta);
break;
default :
default:
break;
}

if (destination != null)
MoveToDestination(delta);
if (destination != null) MoveToDestination(delta);
}

public void approach(float delta) {
Expand Down
18 changes: 18 additions & 0 deletions core/src/main/java/io/github/annabeths/Boats/Boat.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ public abstract class Boat extends PhysicsObject implements IHealth {
protected float shotDelay = 0.5f;
protected float timeSinceLastShot = 0f;

/**
* @author James Burnell
* @tt.updated Assessment 2
* @param controller the game controller
* @param position the position of the boat
* @param texLoc the texture file location for the boat
*/
public Boat(GameController controller, Vector2 position, String texLoc) {
this.controller = controller;
this.position = position.cpy();
Expand All @@ -47,6 +54,8 @@ public Boat(GameController controller, Vector2 position, String texLoc) {
*
* @param delta time since last frame
* @param multiplier multiplier to set forward or reverse motion (1 or -1)
*
* @since Assessment 1
*/
void Move(float delta, int multiplier) {
// Convention: 0 degrees means the object is pointing right, positive angles are
Expand All @@ -73,6 +82,8 @@ void Move(float delta, int multiplier) {
*
* @param delta time since last frame
* @param multiplier turn anti-clockwise if +ve, clockwise if -ve
*
* @since Assessment 1
*/
void Turn(float delta, float multiplier) {
rotation = rotation + turnSpeed * delta * multiplier;
Expand All @@ -87,6 +98,7 @@ void Turn(float delta, float multiplier) {
*
* @param desiredAngle the angle the boat should end up at
* @param delta the time since the last update
* @since Assessment 2
* @author James Burnell
* @author Hector Woods
*/
Expand Down Expand Up @@ -116,13 +128,16 @@ public void moveTowardsDesiredAngle(float desiredAngle, float delta) {
*
* @param x the x position
* @param y the y position
*
* @since Assessment 1
*/
void SetPosition(float x, float y) {
position.x = x;
position.y = y;
sprite.setPosition(x, y);
}

/** @since Assessment 1 */
@Override
public void Draw(SpriteBatch batch) {
sprite.draw(batch);
Expand All @@ -137,6 +152,9 @@ public void Draw(SpriteBatch batch) {
* @param spdMul the speed multiplier
*
* @return A new projectile object
*
* @since Assessment 2
* @author James Burnell
*/
protected Projectile createProjectile(ProjectileData type, float rotationOffset, float dmgMul,
float spdMul) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* A boat that attacks the player
*
* @since Assessment 2
* @author James Burnell
*/
public class EnemyBoat extends AttackBoat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/**
* A type of boat that attacks enemy ships
*
* @since Assessment 2
* @author Hector Woods
*/
public class FriendlyBoat extends AttackBoat {
Expand Down
15 changes: 15 additions & 0 deletions core/src/main/java/io/github/annabeths/Boats/NeutralBoat.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

public class NeutralBoat extends AIBoat {

/**
* @author James Burnell
* @tt.updated Assessment 2
* @param controller the game controller
* @param initialPosition the position of the boat
*/
public NeutralBoat(GameController controller, Vector2 initialPosition) {
super(controller, initialPosition, "img/entity/boat_neutral.png");

Expand All @@ -23,6 +29,11 @@ public NeutralBoat(GameController controller, Vector2 initialPosition) {
this.turnSpeed = 150;
}

/**
* @author James Burnell
* @author Ben Faulker
* @tt.updated Assessment 2
*/
public void Destroy() {
killOnNextTick = true;
if (MathUtils.randomBoolean(0.2f)) {
Expand All @@ -34,6 +45,10 @@ public void Shoot() {
// Ignore, neutral boats do not shoot, but this must be defined
}

/**
* @author James Burnell
* @tt.updated Assessment 2
*/
public void OnCollision(PhysicsObject object) {
float dmgToInflict = 0;
// whether or not the object belongs to the player
Expand Down
68 changes: 67 additions & 1 deletion core/src/main/java/io/github/annabeths/Boats/PlayerBoat.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public class PlayerBoat extends Boat {
/** The type of projectile currently in use */
public ProjectileData activeProjectileType;

/**
* @author James Burnell
* @tt.updated Assessment 2
* @param controller the game controller
* @param initialPosition the position of the boat
*/
public PlayerBoat(GameController controller, Vector2 initialPosition) {
super(controller, initialPosition, "img/entity/boat1.png");

Expand All @@ -73,6 +79,10 @@ public PlayerBoat(GameController controller, Vector2 initialPosition) {

}

/**
* @author James Burnell
* @tt.updated Assessment 2
*/
@Override
public void Update(float delta) {
boolean rapidFire = activePowerups.containsKey(PowerupType.RAPIDFIRE);
Expand All @@ -86,6 +96,11 @@ public void Update(float delta) {

}

/**
* @author James Burnell
* @since Assessment 2
* @param delta the time since the last update
*/
public void updatePowerups(float delta) {
// Subtract delta time from each active power up
activePowerups.replaceAll((k, v) -> v - delta);
Expand All @@ -97,6 +112,10 @@ public void updatePowerups(float delta) {
* Processes keyboard and mouse inputs
*
* @param delta the time since the last update in seconds
* @since Assessment 2
* @author James Burnell
* @author Hector Woods
* @author Ben Faulkner
*/
public void processInput(float delta) {
boolean up = input.isKeyPressed(Keys.W);
Expand All @@ -123,6 +142,11 @@ public void processInput(float delta) {
processPowerupInput(delta);
}

/**
* @author James Burnell
* @since Assessment 2
* @param delta the time since the last update
*/
public void processPowerupInput(float delta) {
PowerupType[] powerups = PowerupType.values();
if (input.isKeyJustPressed(Keys.NUM_1) || input.isKeyJustPressed(Keys.NUMPAD_1))
Expand All @@ -141,6 +165,9 @@ public void processPowerupInput(float delta) {
* Method that executes when a collision is detected
*
* @param other the other object, as a PhysicsObject to be generic
* @author Annabeth
* @author James Burnell
* @tt.updated Assessment 2
*/
@Override
public void OnCollision(PhysicsObject other) {
Expand All @@ -162,18 +189,31 @@ public void OnCollision(PhysicsObject other) {
if (!isInvincible()) damage(dmgToInflict);
}

/**
* @author James Burnell
* @since Assessment 2
*/
@Override
public void damage(float dmg) {
if (isInvincible()) return; // no damage if invincible
dmg = Math.max(dmg - defense, 0); // subtract defense
HP = MathUtils.clamp(HP - dmg, 0, maxHP);
}

/** @return {@code true} if invincibility powerup is active */
/**
* @return {@code true} if invincibility powerup is active
*
* @author James Burnell
* @since Assessment 2
*/
public boolean isInvincible() {
return activePowerups.containsKey(PowerupType.INVINCIBILITY);
}

/**
* @author James Burnell
* @tt.updated Assessment 2
*/
@Override
public void Shoot() {

Expand All @@ -191,6 +231,11 @@ public void Shoot() {

}

/**
* @author James Burnell
* @since Assessment 2
* @param dmgMul the damage multiplier
*/
public void shootRay(float dmgMul) {
float angle = getAngleBetweenMouseAndBoat();
angle += MathUtils.random(-5, 5); // randomize ray so it is not perfect
Expand All @@ -207,6 +252,10 @@ public void shootRay(float dmgMul) {
* this by unwrapping the cursor position with the controller camera.
*
* @return The angle in degrees
*
* @author James Burnell
* @since Assessment 2
*
*/
public float getAngleBetweenMouseAndBoat() {
int mouseX = input.getX();
Expand All @@ -218,6 +267,11 @@ public float getAngleBetweenMouseAndBoat() {
return pos.sub(getCenter()).angleDeg();
}

/**
* @author James Burnell
* @since Assessment 2
* @param dmgMul the damage multiplier
*/
public void shootStock(float dmgMul) {
if (activePowerups.containsKey(PowerupType.STARBURSTFIRE)) {
for (int i = 0; i < 360; i += 45) {
Expand All @@ -234,6 +288,11 @@ public void shootStock(float dmgMul) {
}
}

/**
* @author James Burnell
* @since Assessment 2
* @return the damage multiplier
*/
public float getDamageMul() {
float dmgMul = activePowerups.containsKey(PowerupType.DAMAGE) ? 2 : 1;
// multiply by the overall damage multiplier
Expand Down Expand Up @@ -295,6 +354,10 @@ public void Heal(int amount, float delta) {
* @param powerup the powerup to activate
* @return {@code true} if powerup is in the collection and was activated,
* {@code false} otherwise
*
* @author James Burnell
* @since Assessment 2
*
*/
public boolean activatePowerup(PowerupType powerup) {
boolean canActivate = collectedPowerups.containsKey(powerup)
Expand All @@ -319,6 +382,9 @@ public boolean activatePowerup(PowerupType powerup) {
* @param powerup the powerup to collect
* @return {@code true} if powerup was received, {@code false} if player already
* had maximum powerups stored
*
* @author James Burnell
* @since Assessment 2
*/
public boolean receivePower(PowerupType powerup) {
int amount = collectedPowerups.getOrDefault(powerup, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import io.github.annabeths.Boats.PlayerBoat;
import io.github.annabeths.GameGenerics.PhysicsObject;

/** @author Ben Faulkner */
/**
* @since Assessment 2
* @author Ben Faulkner
*/
public class Powerup extends PhysicsObject {

// id of powerup given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import com.badlogic.gdx.math.MathUtils;

/** @author James Burnell */
/**
* @author James Burnell
* @since Assessment 2
*/
public enum PowerupType {

SPEED("Speed", 10, "speed.png", "speed-boost.mp3"),
Expand Down
Loading

0 comments on commit b65d1cf

Please sign in to comment.