Package com.dragonboat.game
Class Opponent
- java.lang.Object
-
- com.dragonboat.game.Boat
-
- com.dragonboat.game.Opponent
-
public class Opponent extends Boat
Represents a opponent boat with AI.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
ai(int backgroundOffset)
Controls the AI behaviour of the boat.int
SetRandomBoat(java.util.ArrayList<java.lang.Integer> possibleBoats)
Assigns a random boat template to the boat.-
Methods inherited from class com.dragonboat.game.Boat
AdvanceTextureFrame, ApplyDamage, applyPenalty, CheckCollisions, CheckIfInLane, DecreaseSpeed, DecreaseTiredness, finished, GenerateTextureFrames, getAcceleration, getCurrentSpeed, getDurability, getFastestTime, getHeight, getManeuverability, getMaxSpeed, getName, getPenalty, getProgress, getRobustness, getTiredness, getX, getY, IncreaseSpeed, IncreaseTiredness, MoveForward, Reset, ResetFastestLegTime, setFinished, setLane, setStats, setStats, setTexture, setTextureFrames, SteerLeft, SteerRight, UpdateFastestTime
-
-
-
-
Constructor Detail
-
Opponent
public Opponent(int yPosition, int width, int height, Lane lane, java.lang.String name)
Creates a opponent instance.- Parameters:
yPosition
- Y-position.width
- Width of the boat.height
- Height of the boat.lane
- Lane for the boat.name
- Name of the opponent.
-
-
Method Detail
-
ai
public void ai(int backgroundOffset)
Controls the AI behaviour of the boat.
Changes the movement path of the boat.
AI new path selection:
1) If not in lane, go back to lane.
2) If obstacle ahead, avoid the obstacle. If dead ahead, slow down.
3) If nothing, speed up.
- Parameters:
backgroundOffset
-
-
SetRandomBoat
public int SetRandomBoat(java.util.ArrayList<java.lang.Integer> possibleBoats)
Assigns a random boat template to the boat.
This includes stats and texture.
- Parameters:
possibleBoats
- List of remaining boat templates that haven't been assigned yet.- Returns:
- Int representing the index of the boat template that was assigned.
-
-