Class Lane


  • public class Lane
    extends java.lang.Object
    Represents a lane on the course.
    • Constructor Summary

      Constructors 
      Constructor Description
      Lane​(int leftBoundary, int rightBoundary, int obstacleLimit)
      Creates a lane instance.
      Lane​(int leftBoundary, int rightBoundary, Lane[] lanes, int laneNo)
      Creates a lane instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getLeftBoundary()  
      int getRightBoundary()  
      void RemoveObstacle​(Obstacle obstacle)
      Removes obstacle from obstacle list.
      void SpawnObstacle​(java.util.HashMap<java.lang.String,​com.badlogic.gdx.graphics.Texture> textures, int x, int y, java.lang.String obstacleType)
      Spawns obstacle in the lane.
      • Methods inherited from class java.lang.Object

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

      • LEFTBOUNDARY

        public int LEFTBOUNDARY
      • RIGHTBOUNDARY

        public int RIGHTBOUNDARY
      • obstacles

        protected java.util.ArrayList<Obstacle> obstacles
      • obstacleLimit

        protected int obstacleLimit
      • lanes

        protected Lane[] lanes
      • laneNo

        protected int laneNo
    • Constructor Detail

      • Lane

        public Lane​(int leftBoundary,
                    int rightBoundary,
                    Lane[] lanes,
                    int laneNo)
        Creates a lane instance.
        Parameters:
        leftBoundary - X-position for the left boundary of the lane.
        rightBoundary - X-position for the right boundary of the lane.
        lanes - reference to game lanes
        laneNo - this lane's number
      • Lane

        public Lane​(int leftBoundary,
                    int rightBoundary,
                    int obstacleLimit)
        Creates a lane instance.
        Parameters:
        leftBoundary - X-position for the left boundary of the lane.
        rightBoundary - X-position for the right boundary of the lane.
        obstacleLimit - Limit for the number of obstacles in the lane.
    • Method Detail

      • SpawnObstacle

        public void SpawnObstacle​(java.util.HashMap<java.lang.String,​com.badlogic.gdx.graphics.Texture> textures,
                                  int x,
                                  int y,
                                  java.lang.String obstacleType)

        Spawns obstacle in the lane.

        Spawns specified obstacle in the lane. Checks that the obstacle limit hasn't been reached, if not checks the obstacle type for Goose or Log and instantiates it as the corresponding obstacle, with the correct texture. Then adds it to the Lane's obstacle list.

        Parameters:
        textures - Reference to loaded textures
        x - X-position for the obstacle spawn location.
        y - Y-position for the obstacle spawn location.
        obstacleType - Obstacle type.
      • RemoveObstacle

        public void RemoveObstacle​(Obstacle obstacle)

        Removes obstacle from obstacle list.

        Obstacle should be removed upon collision with boat or leaving the course. area.

        Parameters:
        obstacle - Obstacle to be removed.
      • getLeftBoundary

        public int getLeftBoundary()
        Returns:
        Int representing the x-position of the lane's left boundary.
      • getRightBoundary

        public int getRightBoundary()
        Returns:
        Int representing the x-position of the lane's right boundary.