Package com.dragonboat.game
Class Boat
- java.lang.Object
- 
- com.dragonboat.game.Boat
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected floatACCELERATIONstatic intbankWidthprotected floatcurrentSpeedprotected intdurabilityprotected floatfastestLegTimeprotected booleanfinishedprotected intframeCounterprotected intheightprotected charlabelprotected intlaneNoprotected Lane[]lanesprotected floatlastFrameYprotected floatMANEUVERABILITYstatic intMAX_DURABILITYstatic floatMAX_TIREDNESSprotected floatMAXSPEEDprotected java.lang.Stringnameprotected floatpenaltiesprotected intROBUSTNESScom.badlogic.gdx.graphics.Texturetextureprotected com.badlogic.gdx.graphics.Texture[]textureFramesprotected intthresholdprotected floattirednessprotected intwidthprotected floatxPositionprotected floatyPosition
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidAdvanceTextureFrame()Keeps track of which frame of the animation the boat's texture is on, and sets the texture accordingly.booleanApplyDamage(int obstacleDamage)Decreases the durability of the boat by the obstacle damage divided by the boat's robustness.voidapplyPenalty(float penalty)booleanCheckCollisions(int backgroundOffset)Checks each obstacle in the Lane for a collision.booleanCheckIfInLane()Checks if the boat is between the left boundary and the right boundary of the Lane.voidChooseBoat(char boatChar)Assigns the selected boat template to the boat.voidChooseBoat(int boatNo)Assigns the selected boat template to the boat.voidDecreaseSpeed()Decreases the speed of the boat by 0.015 if the resulting speed is greater than 0.voidDecreaseTiredness()Decreases the tiredness of the boat by 1 if the tiredness is greater than 0.booleanfinished()voidGenerateTextureFrames(char boatName)Generates all frames for animating the boat.floatgetAcceleration()floatgetCurrentSpeed()intgetDurability()floatgetFastestTime()intgetHeight()floatgetManeuverability()floatgetMaxSpeed()java.lang.StringgetName()floatgetPenalty()floatgetProgress(int finishY)intgetRobustness()floatgetTiredness()intgetX()intgetY()voidIncreaseSpeed()If the boat has enough stamina, increase the speed of the boat by the boat's acceleration, if not, do nothing.voidIncreaseTiredness()Increases the tiredness of the boat by 0.75 if the tiredness is less than 100.voidMoveForward()Increases the y-position of the boat respective to the boat's speed, and decreases the speed by 0.08%.voidReset()Resets necessary stats for the next race.voidResetFastestLegTime()Resets the boat's fastest leg time.voidsetFinished(boolean f)voidsetLane(Lane[] lanes, int laneNo)voidsetStats(char boatLabel)Interpolates predetermined stats from a boat label, and sets the stats based on those.voidsetStats(float maxspeed, int robustness, float acceleration, float maneuverability)Implicitly sets the stats of the boat, given each attribute.voidsetTexture(com.badlogic.gdx.graphics.Texture t)voidsetTextureFrames(com.badlogic.gdx.graphics.Texture[] frames)voidSteerLeft()Decreases the x-position of the boat respective to the boat's maneuverability and speed, and decreases the speed by 3%.voidSteerRight()Increases the x-position of the boat respective to the boat's maneuverability and speed, and decreases the speed by 3%.voidUpdateFastestTime(float elapsedTime)Updates the boat's fastest time.
 
- 
- 
- 
Field Detail- 
ROBUSTNESSprotected int ROBUSTNESS 
 - 
ACCELERATIONprotected float ACCELERATION 
 - 
MANEUVERABILITYprotected float MANEUVERABILITY 
 - 
MAXSPEEDprotected float MAXSPEED 
 - 
durabilityprotected int durability 
 - 
yPositionprotected float yPosition 
 - 
xPositionprotected float xPosition 
 - 
penaltiesprotected float penalties 
 - 
widthprotected int width 
 - 
heightprotected int height 
 - 
currentSpeedprotected float currentSpeed 
 - 
fastestLegTimeprotected float fastestLegTime 
 - 
tirednessprotected float tiredness 
 - 
lanesprotected Lane[] lanes 
 - 
laneNoprotected int laneNo 
 - 
textureFramesprotected com.badlogic.gdx.graphics.Texture[] textureFrames 
 - 
frameCounterprotected int frameCounter 
 - 
lastFrameYprotected float lastFrameY 
 - 
texturepublic com.badlogic.gdx.graphics.Texture texture 
 - 
nameprotected java.lang.String name 
 - 
labelprotected char label 
 - 
finishedprotected boolean finished 
 - 
thresholdprotected int threshold 
 - 
bankWidthpublic static int bankWidth 
 - 
MAX_DURABILITYpublic static int MAX_DURABILITY 
 - 
MAX_TIREDNESSpublic static float MAX_TIREDNESS 
 
- 
 - 
Constructor Detail- 
Boatpublic Boat(float yPosition, int width, int height, Lane[] lanes, int laneNo, java.lang.String name)Creates an instance of the player boat.- Parameters:
- yPosition- Y-position of the boat.
- width- Width of the boat.
- height- Height of the boat.
- lanes- Lanes for the boat.
- laneNo- Lane number for the boat.
- name- Name of the boat.
 
 
- 
 - 
Method Detail- 
SteerLeftpublic void SteerLeft() Decreases the x-position of the boat respective to the boat's maneuverability and speed, and decreases the speed by 3%.
 - 
SteerRightpublic void SteerRight() Increases the x-position of the boat respective to the boat's maneuverability and speed, and decreases the speed by 3%.
 - 
MoveForwardpublic void MoveForward() Increases the y-position of the boat respective to the boat's speed, and decreases the speed by 0.08%.
 - 
IncreaseSpeedpublic void IncreaseSpeed() If the boat has enough stamina, increase the speed of the boat by the boat's acceleration, if not, do nothing.
 - 
DecreaseSpeedpublic void DecreaseSpeed() Decreases the speed of the boat by 0.015 if the resulting speed is greater than 0.
 - 
CheckCollisionspublic boolean CheckCollisions(int backgroundOffset) Checks each obstacle in the Lane for a collision.- Parameters:
- backgroundOffset- How far up the course the player is.
- Returns:
- Boolean representing if a collision occurs.
 
 - 
ApplyDamagepublic boolean ApplyDamage(int obstacleDamage) Decreases the durability of the boat by the obstacle damage divided by the boat's robustness.- Parameters:
- obstacleDamage- Amount of damage an Obstacle inflicts on the boat.
- Returns:
- Boolean representing whether the durability of the boat is below 0.
 
 - 
CheckIfInLanepublic boolean CheckIfInLane() Checks if the boat is between the left boundary and the right boundary of the Lane.- Returns:
- Boolean representing whether the Boat is in the Lane.
 
 - 
UpdateFastestTimepublic void UpdateFastestTime(float elapsedTime) Updates the boat's fastest time.- Parameters:
- elapsedTime- Time it took the boat to finish the current race.
 
 - 
IncreaseTirednesspublic void IncreaseTiredness() Increases the tiredness of the boat by 0.75 if the tiredness is less than 100.
 - 
DecreaseTirednesspublic void DecreaseTiredness() Decreases the tiredness of the boat by 1 if the tiredness is greater than 0.
 - 
AdvanceTextureFramepublic void AdvanceTextureFrame() Keeps track of which frame of the animation the boat's texture is on, and sets the texture accordingly.
 - 
GenerateTextureFramespublic void GenerateTextureFrames(char boatName) Generates all frames for animating the boat.- Parameters:
- boatName- Boat name, used to get correct asset.
 
 - 
ChooseBoatpublic void ChooseBoat(int boatNo) Assigns the selected boat template to the boat. This includes stats and texture. - Parameters:
- boatNo- Number of the boat template selected.
 
 - 
ChooseBoatpublic void ChooseBoat(char boatChar) Assigns the selected boat template to the boat. This includes stats and texture. - Parameters:
- boatChar- Character of the boat template selected.
 
 - 
Resetpublic void Reset() Resets necessary stats for the next race.
 - 
ResetFastestLegTimepublic void ResetFastestLegTime() Resets the boat's fastest leg time.
 - 
setTexturepublic void setTexture(com.badlogic.gdx.graphics.Texture t) - Parameters:
- t- Texture to use.
 
 - 
setTextureFramespublic void setTextureFrames(com.badlogic.gdx.graphics.Texture[] frames) - Parameters:
- frames- Texture frames for animation.
 
 - 
getFastestTimepublic float getFastestTime() - Returns:
- Float representing fastest race/leg time.
 
 - 
getXpublic int getX() - Returns:
- Int representing x-position of boat.
 
 - 
getYpublic int getY() - Returns:
- Int representing y-position of boat.
 
 - 
getHeightpublic int getHeight() - Returns:
- Int representing the y coordinate range of the boat (length).
 
 - 
getNamepublic java.lang.String getName() - Returns:
- String representing name of the boat.
 
 - 
finishedpublic boolean finished() - Returns:
- Boolean representing if the boat has finished the current race.
 
 - 
setFinishedpublic void setFinished(boolean f) - Parameters:
- f- Boolean representing if the boat has finished the race.
 
 - 
getCurrentSpeedpublic float getCurrentSpeed() - Returns:
- Float representing the current speed of the boat.
 
 - 
getProgresspublic float getProgress(int finishY) - Parameters:
- finishY- Y-position of the finish line.
- Returns:
- Float representing the progress of the boat from 0 to 1.
 
 - 
setStatspublic void setStats(float maxspeed, int robustness, float acceleration, float maneuverability)Implicitly sets the stats of the boat, given each attribute.- Parameters:
- maxspeed- Top speed the boat can reach.
- robustness- How resilient to obstacle damage the boat is.
- acceleration- How much the speed increases each frame.
- maneuverability- How easily the boat can move left or right.
 
 - 
setStatspublic void setStats(char boatLabel) Interpolates predetermined stats from a boat label, and sets the stats based on those.- Parameters:
- boatLabel- A character between A-G representing a specific boat.
 
 - 
getManeuverabilitypublic float getManeuverability() - Returns:
- Float representing the maneuverability of the boat.
 
 - 
getAccelerationpublic float getAcceleration() - Returns:
- Float representing the acceleration of the boat.
 
 - 
getRobustnesspublic int getRobustness() - Returns:
- Int representing the robustness of the boat.
 
 - 
getDurabilitypublic int getDurability() - Returns:
- Int representing the durability of the boat.
 
 - 
getMaxSpeedpublic float getMaxSpeed() - Returns:
- Int representing the maximum speed of the boat.
 
 - 
getTirednesspublic float getTiredness() - Returns:
- Float representing the tiredness of the boat crew.
 
 - 
getPenaltypublic float getPenalty() - Returns:
- Float representing the time penalty incurred for the current race.
 
 - 
applyPenaltypublic void applyPenalty(float penalty) - Parameters:
- penalty- Float to add to the boat's penalty total for the current race.
 
 - 
setLanepublic void setLane(Lane[] lanes, int laneNo) - Parameters:
- lanes- Lanes object for the boat.
- laneNo- This boat's lane number.
 
 
- 
 
-