Class Obstacle

  • Direct Known Subclasses:
    Goose, Log

    public class Obstacle
    extends java.lang.Object
    Represents an obstacle on the course.
    See Also:
    Log, Goose
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int height  
      com.badlogic.gdx.graphics.Texture texture  
      int width  
      protected float xPosition  
      protected float yPosition  
    • Constructor Summary

      Constructors 
      Constructor Description
      Obstacle​(int damage, int xPosition, int yPosition, int width, int height, com.badlogic.gdx.graphics.Texture texture)
      Creates an obstacle instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getDamage()  
      int getHeight()  
      com.badlogic.gdx.graphics.Texture getTexture()  
      float getX()  
      float getY()  
      void Move​(float moveVal, int backgroundOffset)
      Moves the obstacle.
      void setX​(float xPosition)  
      void setY​(float yPosition)  
      • Methods inherited from class java.lang.Object

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

      • yPosition

        protected float yPosition
      • xPosition

        protected float xPosition
      • width

        public int width
      • height

        public int height
      • texture

        public com.badlogic.gdx.graphics.Texture texture
    • Constructor Detail

      • Obstacle

        public Obstacle​(int damage,
                        int xPosition,
                        int yPosition,
                        int width,
                        int height,
                        com.badlogic.gdx.graphics.Texture texture)
        Creates an obstacle instance.
        Parameters:
        damage - Damage the obstacle can inflict on a boat.
        xPosition - X-position.
        yPosition - Y-position.
        width - Width of the obstacle.
        height - Height of the obstacle.
        texture - Texture asset for the obstacle.
    • Method Detail

      • Move

        public void Move​(float moveVal,
                         int backgroundOffset)
        Moves the obstacle.
        Parameters:
        moveVal - Distance to move the object by.
        backgroundOffset - Offset from screen to course coordinates.
      • getDamage

        public int getDamage()
        Returns:
        Int representing damage the obstacle inflicts upon collision.
      • getX

        public float getX()
        Returns:
        Float representing the x-position.
      • getY

        public float getY()
        Returns:
        Float representing the y-position.
      • setY

        public void setY​(float yPosition)
        Parameters:
        yPosition - Y-position.
      • setX

        public void setX​(float xPosition)
        Parameters:
        xPosition - X-position.
      • getTexture

        public com.badlogic.gdx.graphics.Texture getTexture()
        Returns:
        Texture asset for obstacle.
      • getHeight

        public int getHeight()
        Returns:
        Int representing the height of the obstacle.