Package com.entities
Class Projectile
- java.lang.Object
-
- com.badlogic.gdx.graphics.g2d.TextureRegion
-
- com.badlogic.gdx.graphics.g2d.Sprite
-
- com.sprites.SimpleSprite
-
- com.sprites.MovementSprite
-
- com.entities.Projectile
-
public class Projectile extends MovementSprite
The Projectile implementation. A sprite capable of moving and colliding with other sprites.- Since:
- 09/01/2020
-
-
Constructor Summary
Constructors Constructor Description Projectile(com.badlogic.gdx.graphics.Texture texture, float x, float y, int damage, GameScreen gameScreen)Overloaded constructor containing all possible parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcalculateTrajectory(SimpleSprite target)Calculates the trajectory from the projectiles starting point to the target point.intgetDamage()booleanisOutOfMap()Gets whether the projectile is ready to be removed.voidupdate(com.badlogic.gdx.graphics.g2d.Batch batch)Update the position and direction of the projectile every frame.-
Methods inherited from class com.sprites.MovementSprite
applyAcceleration, getMaxSpeed, getPolygonVertices, setAccelerationRate, setDecelerationRate, setMaxSpeed, setSpeed
-
Methods inherited from class com.sprites.SimpleSprite
decreaseInternalTime, dispose, drawDebug, getCentre, getCentreX, getCentreY, getDamageHitBox, getHealthBar, getHeight, getInternalTime, getMovementHitBox, getWidth, removeSprite, resetRotation, rotate, setInternalTime, setMovementHitBox, setSize
-
Methods inherited from class com.badlogic.gdx.graphics.g2d.Sprite
draw, draw, flip, getBoundingRectangle, getColor, getOriginX, getOriginY, getRotation, getScaleX, getScaleY, getVertices, getX, getY, rotate90, scale, scroll, set, setAlpha, setBounds, setCenter, setCenterX, setCenterY, setColor, setColor, setFlip, setOrigin, setOriginBasedPosition, setOriginCenter, setPackedColor, setPosition, setRegion, setRotation, setScale, setScale, setU, setU2, setV, setV2, setX, setY, translate, translateX, translateY
-
Methods inherited from class com.badlogic.gdx.graphics.g2d.TextureRegion
getRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, split, split
-
-
-
-
Constructor Detail
-
Projectile
public Projectile(com.badlogic.gdx.graphics.Texture texture, float x, float y, int damage, GameScreen gameScreen)Overloaded constructor containing all possible parameters. Creates a projectile capable of moving and colliding with the tiledMap and other sprites. It also requires an ID so that it can be focused with the camera. Drawn with the given texture at the given position.- Parameters:
texture- The texture used to draw the projectile with.x- The x-coordinate the projectile will start at.y- The y-coordinate the projectile will start at.damage- The amount of damage projectile does when it hitsgameScreen- The gamescreen instance to get the difficulty
-
-
Method Detail
-
update
public void update(com.badlogic.gdx.graphics.g2d.Batch batch)
Update the position and direction of the projectile every frame.- Overrides:
updatein classMovementSprite- Parameters:
batch- The batch to draw onto.
-
calculateTrajectory
public void calculateTrajectory(SimpleSprite target)
Calculates the trajectory from the projectiles starting point to the target point.- Parameters:
target- The target the projectile is fired at
-
isOutOfMap
public boolean isOutOfMap()
Gets whether the projectile is ready to be removed. It needs to be outside of the map before it disappears.- Returns:
- Whether the projectile can be removed.
-
getDamage
public int getDamage()
-
-