Package com.entities

Class Projectile


  • public class Projectile
    extends MovementSprite
    The Projectile implementation. A sprite capable of moving and colliding with other sprites.
    Since:
    09/01/2020
    • 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 hits
        gameScreen - 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:
        update in class MovementSprite
        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()