Class Boat

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected float agility
      The agility of the boat.
      protected BoatType boatType
      Boat Type of boat used to remember the chosen boat type
      protected float buff
      Controlled by powerups, controls how much damage the boat receives
      protected float collisionTime
      Timer used to countdown for when the boat can move again after a collision.
      protected float distanceTravelled
      The total distance travelled by the boat.
      protected com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator generator
      Generator for FreeType Font.
      protected float health
      The health of the boat.
      protected com.badlogic.gdx.graphics.g2d.BitmapFont healthFont
      Font for Health Bar.
      protected Lane lane
      The lane of the boat.
      protected Hitbox laneBox
      The lanes hit box, use to determine if the boat is still in the lane.
      protected com.badlogic.gdx.graphics.g2d.GlyphLayout layout
      The formatter used to align the text on-screen.
      protected float maxStamina
      The maximum amount of stamina the boat can have.
      private int minBoostSpeed
      The minimum amount of speed gained from using stamina.
      protected java.lang.String name
      The name of the boat.
      protected com.badlogic.gdx.graphics.g2d.BitmapFont nameFont
      Font for Name Tag.
      protected com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter parameter
      Parameter for FreeType Font.
      protected float penaltyTime
      Total time penalties the boat got.
      protected boolean recentCollision
      If there has been a recent collision.
      protected float speed
      The speed of the boat.
      protected float stamina
      The stamina of the boat.
      protected com.badlogic.gdx.graphics.g2d.BitmapFont staminaFont
      Font for Stamina Bar.
      private float staminaRate
      The rate at which the stamina is used or regenerated at.
      protected float time
      The current time of the boat in the current round.
      protected float totalTime
      Total time added up across all rounds.
    • Constructor Summary

      Constructors 
      Constructor Description
      Boat​(BoatType boat, Lane lane, java.lang.String name)
      Creates a Boat with the specified BoatType for pre-defined values, a Lane to give the boat its position and a name for easy identification.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addHealth​(float change)
      Increase the current boat health.
      void addSpeed​(float inc)
      Increase the inc of the boat.
      void addStamina​(float change)
      Increase the current boat stamina.
      protected boolean checkCollisions()
      Check for collisions by comparing positions of collidables in the lane to the boat position.
      void dispose()
      Dispose of the fonts used in the HUD and then perform Entity's dispose.
      boolean equals​(java.lang.Object obj)  
      float getAgility()
      Get the current agility of the boat.
      BoatType getBoatType()
      Get the boat type.
      float getBuff()  
      float getDistanceTravelled()
      Get the total distance travelled by the boat so far.
      float getHealth()
      Get the current health of the boat.
      Lane getLane()
      Get the lane that the boat is in.
      java.lang.String getName()
      Get the name of the boat.
      float getPenaltyTime()  
      float getSpeed()
      Get the speed of the boat.
      float getStamina()
      Get the current stamina of the boat.
      float getTime()
      Get the boat time
      float getTotalTime()
      Get the total boat time
      com.badlogic.gdx.math.Vector2 getVelocity()
      Get the current velocity of the boat.
      protected float regenerateStamina()
      Get the amount of stamina that will be gained for the current amount of stamina.
      void render​(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Render the boat and its lane contents.
      void restore()  
      void save()  
      void setBuff​(float buff)  
      void setTestTime​(float newtime)
      Set the boat time to the newtime value.
      void setTime​(float nowTime)
      Set the boat time
      void setTotalTime​(float nowTime)
      Set the total boat time.
      void update​(float deltaTime)
      Update the position of the boat in relation to the amount of time passed.
      void updateYPosition​(int lineHeight, int raceDistance)
      Update the vertical position of the boat onscreen.
      protected float useStamina()
      Get the amount of stamina to use for the current amount of stamina.
      protected float velocityPercentage()
      Return a scalar to multiply the velocity by when using stamina.
      • Methods inherited from class java.lang.Object

        clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • staminaRate

        private final float staminaRate
        The rate at which the stamina is used or regenerated at.
        See Also:
        Constant Field Values
      • minBoostSpeed

        private final int minBoostSpeed
        The minimum amount of speed gained from using stamina.
        See Also:
        Constant Field Values
      • layout

        protected com.badlogic.gdx.graphics.g2d.GlyphLayout layout
        The formatter used to align the text on-screen.
      • health

        protected float health
        The health of the boat.
      • stamina

        protected float stamina
        The stamina of the boat.
      • agility

        protected final float agility
        The agility of the boat.
      • speed

        protected float speed
        The speed of the boat.

        This is the speed attribute of the boat, not how fast it actually is moving.

      • maxStamina

        protected float maxStamina
        The maximum amount of stamina the boat can have.
      • lane

        protected Lane lane
        The lane of the boat.
      • laneBox

        protected Hitbox laneBox
        The lanes hit box, use to determine if the boat is still in the lane.
      • name

        protected java.lang.String name
        The name of the boat.
      • distanceTravelled

        protected float distanceTravelled
        The total distance travelled by the boat.
      • recentCollision

        protected boolean recentCollision
        If there has been a recent collision.
      • collisionTime

        protected float collisionTime
        Timer used to countdown for when the boat can move again after a collision.
      • boatType

        protected BoatType boatType
        Boat Type of boat used to remember the chosen boat type
      • time

        protected float time
        The current time of the boat in the current round.
      • totalTime

        protected float totalTime
        Total time added up across all rounds.
      • penaltyTime

        protected float penaltyTime
        Total time penalties the boat got.
      • buff

        protected float buff
        Controlled by powerups, controls how much damage the boat receives
      • generator

        protected com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator generator
        Generator for FreeType Font.
      • parameter

        protected com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter parameter
        Parameter for FreeType Font.
      • healthFont

        protected com.badlogic.gdx.graphics.g2d.BitmapFont healthFont
        Font for Health Bar.
      • staminaFont

        protected com.badlogic.gdx.graphics.g2d.BitmapFont staminaFont
        Font for Stamina Bar.
      • nameFont

        protected com.badlogic.gdx.graphics.g2d.BitmapFont nameFont
        Font for Name Tag.
    • Constructor Detail

      • Boat

        public Boat​(BoatType boat,
                    Lane lane,
                    java.lang.String name)
        Creates a Boat with the specified BoatType for pre-defined values, a Lane to give the boat its position and a name for easy identification.
        Parameters:
        boat - The type of boat to use as a template.
        lane - The lane the boat is in.
        name - The name of the boat.
    • Method Detail

      • velocityPercentage

        protected float velocityPercentage()
        Return a scalar to multiply the velocity by when using stamina.
        Returns:
        A float between 0.25 and 1 which is then scaled by Settings.STAMINA_SPEED_DIVISION.
      • useStamina

        protected float useStamina()
        Get the amount of stamina to use for the current amount of stamina.

        The amount of stamina that gets used per cycle is not linear. The more stamina you have the slower it is used, and the less stamina the faster.

        Returns:
        A float of how much stamina will be used.
      • regenerateStamina

        protected float regenerateStamina()
        Get the amount of stamina that will be gained for the current amount of stamina.
        Returns:
        A float of how much stamina will be gained.
      • update

        public void update​(float deltaTime)
        Update the position of the boat in relation to the amount of time passed.
        Parameters:
        deltaTime - The time passed since the last frame.
      • render

        public void render​(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
        Render the boat and its lane contents. Renders the boat as well as its health and stamina.
        Overrides:
        render in class Entity
        Parameters:
        batch - The SpriteBatch that the renders will be added to.
      • checkCollisions

        protected boolean checkCollisions()
        Check for collisions by comparing positions of collidables in the lane to the boat position. Then removing those that have been collided with and applying their effects to the boat.
        Returns:
        True if a collision occurred, False if no collision.
      • updateYPosition

        public void updateYPosition​(int lineHeight,
                                    int raceDistance)
        Update the vertical position of the boat onscreen.

        This is not implemented in the generic Boat class and must be implemented in the specific Boat kind.

        Parameters:
        lineHeight - The height of the finish line Entity.
        raceDistance - The length of the race.
      • addSpeed

        public void addSpeed​(float inc)
        Increase the inc of the boat.
        Parameters:
        inc - amount by which to increase speed
      • addHealth

        public void addHealth​(float change)
        Increase the current boat health.
        Parameters:
        change - The amount of health to be added.
      • addStamina

        public void addStamina​(float change)
        Increase the current boat stamina.
        Parameters:
        change - The amount of health to be added.
      • getVelocity

        public com.badlogic.gdx.math.Vector2 getVelocity()
        Get the current velocity of the boat.
        Returns:
        A Vector2 of the boats current velocity.
      • getSpeed

        public float getSpeed()
        Get the speed of the boat.

        This is the speed property of the boat, not the speed at which it is moving.

        Returns:
        The speed of the boat.
      • getHealth

        public float getHealth()
        Get the current health of the boat.
        Returns:
        The health of the boat as a float.
      • getStamina

        public float getStamina()
        Get the current stamina of the boat.
        Returns:
        The stamina of the boat as a float.
      • getAgility

        public float getAgility()
        Get the current agility of the boat.
        Returns:
        The agility of the boat as a float.
      • getLane

        public Lane getLane()
        Get the lane that the boat is in.
        Returns:
        The actual Lane object the boat is in.
      • getName

        public java.lang.String getName()
        Get the name of the boat.
        Returns:
        A string of the boats name.
      • getBoatType

        public BoatType getBoatType()
        Get the boat type.
        Returns:
        A BoatType.
      • getTime

        public float getTime()
        Get the boat time
        Returns:
        A float of boat time
      • setTime

        public void setTime​(float nowTime)
        Set the boat time
        Parameters:
        nowTime - The time passed since last call.
      • setTestTime

        public void setTestTime​(float newtime)
        Set the boat time to the newtime value. Created to aid testing.
        Parameters:
        newtime - the new time value.
      • getTotalTime

        public float getTotalTime()
        Get the total boat time
        Returns:
        A float of total boat time
      • setTotalTime

        public void setTotalTime​(float nowTime)
        Set the total boat time.
        Parameters:
        nowTime - The time passed since last call.
      • getPenaltyTime

        public float getPenaltyTime()
      • getDistanceTravelled

        public float getDistanceTravelled()
        Get the total distance travelled by the boat so far.
        Returns:
        A float of the distance travelled.
      • setBuff

        public void setBuff​(float buff)
      • getBuff

        public float getBuff()
      • dispose

        public void dispose()
        Dispose of the fonts used in the HUD and then perform Entity's dispose.
        Overrides:
        dispose in class Entity
      • restore

        public void restore()
      • save

        public void save()
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class Entity