Package com.dragonboat.game
Class Lane
- java.lang.Object
-
- com.dragonboat.game.Lane
-
public class Lane extends java.lang.Object
Represents a lane on the course.
-
-
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(int x, int y, java.lang.String obstacleType)
Spawns obstacle in the lane.
-
-
-
Field Detail
-
obstacles
protected java.util.ArrayList<Obstacle> obstacles
-
-
Constructor Detail
-
Lane
public Lane(int leftBoundary, int rightBoundary)
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.
-
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(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:
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.
-
-