Package com.dragonboatrace.tools
Class Lane
- java.lang.Object
-
- com.dragonboatrace.tools.Lane
-
public class Lane extends java.lang.Object
Represents a Lane in aRace
.
-
-
Field Summary
Fields Modifier and Type Field Description private Hitbox
area
The hit box of the lane, used to check if a boat is in the lane.private java.util.ArrayList<Collidable>
collidables
A list of the collidables currently in the lane.private java.util.ArrayList<java.lang.Float>
randomWaitTimes
A list of times to wait before adding a new collidable to the lane.
-
Constructor Summary
Constructors Constructor Description Lane(com.badlogic.gdx.math.Vector2 pos, int width, int round)
Creates a new lane at a position and with a width and uses the round number to change the number of collidables.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
java.util.ArrayList<Collidable>
getCollidables()
Get the list of all collidables in the lane.Hitbox
getHitbox()
Get the lanes hit boxprivate void
populateList(int round)
Fill the list with collidables that will start at random times.private Collidable
randomCollidable()
Create a new randomCollidable
void
render(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
Render the collidables in the lane.void
replaceCollidable()
Create a random time at which to add anCollidable
to the lane.void
update(float deltaTime, float velY)
Update the collidables in the lane, remove any that are no longer on screen and replace them at a random time.
-
-
-
Field Detail
-
area
private final Hitbox area
The hit box of the lane, used to check if a boat is in the lane.
-
collidables
private final java.util.ArrayList<Collidable> collidables
A list of the collidables currently in the lane.
-
randomWaitTimes
private final java.util.ArrayList<java.lang.Float> randomWaitTimes
A list of times to wait before adding a new collidable to the lane.
-
-
Constructor Detail
-
Lane
public Lane(com.badlogic.gdx.math.Vector2 pos, int width, int round)
Creates a new lane at a position and with a width and uses the round number to change the number of collidables.- Parameters:
pos
- The position of the lane in the screen.width
- The width of the lane.round
- The current round, used to increase difficulty.
-
-
Method Detail
-
update
public void update(float deltaTime, float velY)
Update the collidables in the lane, remove any that are no longer on screen and replace them at a random time.- Parameters:
deltaTime
- The time since the last frame.velY
- The y-velocity of the boat in the lane.
-
render
public void render(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
Render the collidables in the lane.- Parameters:
batch
- The SpriteBatch to be added to.
-
getCollidables
public java.util.ArrayList<Collidable> getCollidables()
Get the list of all collidables in the lane.- Returns:
- An
ArrayList
of typeCollidable
with all the collidables in the lane.
-
getHitbox
public Hitbox getHitbox()
Get the lanes hit box- Returns:
- A
Hitbox
representing the lanes area.
-
replaceCollidable
public void replaceCollidable()
Create a random time at which to add anCollidable
to the lane.
-
randomCollidable
private Collidable randomCollidable()
Create a new randomCollidable
- Returns:
- a new
Collidable
in the lanes area.
-
populateList
private void populateList(int round)
Fill the list with collidables that will start at random times.- Parameters:
round
- The current round increases the number of collidables.
-
dispose
public void dispose()
-
-