Package com.dragonboatrace.tools
Class Lane
- java.lang.Object
-
- com.dragonboatrace.tools.Lane
-
public class Lane extends java.lang.ObjectRepresents a Lane in aRace.
-
-
Field Summary
Fields Modifier and Type Field Description private HitboxareaThe hit box of the lane, used to check if a boat is in the lane.private java.util.ArrayList<Collidable>collidablesA list of the collidables currently in the lane.private java.util.ArrayList<java.lang.Float>randomWaitTimesA 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 voiddispose()java.util.ArrayList<Collidable>getCollidables()Get the list of all collidables in the lane.HitboxgetHitbox()Get the lanes hit boxprivate voidpopulateList(int round)Fill the list with collidables that will start at random times.private CollidablerandomCollidable()Create a new randomCollidablevoidrender(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)Render the collidables in the lane.voidreplaceCollidable()Create a random time at which to add anCollidableto the lane.voidupdate(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
ArrayListof typeCollidablewith all the collidables in the lane.
-
getHitbox
public Hitbox getHitbox()
Get the lanes hit box- Returns:
- A
Hitboxrepresenting the lanes area.
-
replaceCollidable
public void replaceCollidable()
Create a random time at which to add anCollidableto the lane.
-
randomCollidable
private Collidable randomCollidable()
Create a new randomCollidable- Returns:
- a new
Collidablein 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()
-
-