Package com.dragonboatrace.entities
Class Collidable
- java.lang.Object
-
- com.dragonboatrace.entities.Entity
-
- com.dragonboatrace.entities.Collidable
-
public class Collidable extends Entity
Represents a Collidable.
-
-
Field Summary
Fields Modifier and Type Field Description private CollidableEffecteffectEffect the collidable will have on the boat upon collision (positive or negative)private floatspeedThe speed of the collidable.private CollidableTypetype
-
Constructor Summary
Constructors Constructor Description Collidable(CollidableType type, float laneLeftBound, int laneWidth)Creates a new Collidable of a specific type and bounds in which it can be created.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.badlogic.gdx.math.Vector2getPos()The position of the collidable.floatgetSpeed()Get the collidables speed attribute, not the velocity it is moving at currently.booleanisPowerup()Is the object a powerup or an obstaclevoidtakeEffect(Boat boat)Invoke the effect of the collidable on the boat.voidupdate(float deltaTime, float velY)Update the collidable's position relative to the time passed since last frame and the velocity of the boat in that lane.
-
-
-
Field Detail
-
speed
private final float speed
The speed of the collidable.
-
effect
private final CollidableEffect effect
Effect the collidable will have on the boat upon collision (positive or negative)
-
type
private final CollidableType type
-
-
Constructor Detail
-
Collidable
public Collidable(CollidableType type, float laneLeftBound, int laneWidth)
Creates a new Collidable of a specific type and bounds in which it can be created.- Parameters:
type- The type of collidable.laneLeftBound- The starting x value the collidable can be created in.laneWidth- How far from startX the collidable can be created.
-
-
Method Detail
-
update
public void update(float deltaTime, float velY)Update the collidable's position relative to the time passed since last frame and the velocity of the boat in that lane.- Parameters:
deltaTime- The time since last frame.velY- The y-velocity of the boat in the same lane as the collidable.
-
getSpeed
public float getSpeed()
Get the collidables speed attribute, not the velocity it is moving at currently.- Returns:
- A float of the collidables speed attribute.
-
takeEffect
public void takeEffect(Boat boat)
Invoke the effect of the collidable on the boat.- Parameters:
boat- Which boat is affected
-
isPowerup
public boolean isPowerup()
Is the object a powerup or an obstacle- Returns:
- true for powerup, false otherwise
-
getPos
public com.badlogic.gdx.math.Vector2 getPos()
The position of the collidable.- Returns:
- A Vector2 of the position of the collidable.
-
-