Class Bullet


  • public class Bullet
    extends GameObject
    Projectile fired by hostile entities
    Author:
    Riju De
    • Constructor Detail

      • Bullet

        public Bullet​(com.badlogic.gdx.math.Vector2 spawnPos,
                      com.badlogic.gdx.math.Vector2 direction,
                      int speed,
                      float range)
        Parameters:
        spawnPos - Position to spawn the bullet
        direction - direction the bullet will travel in
        speed - speed the bullet should travel at
        range - distance the bullet should travel before it is removed
    • Method Detail

      • fire

        public void fire​(com.badlogic.gdx.math.Vector2 initial)
        Reactivate the bullet and reset position
        Parameters:
        initial - position to set at
      • changeDirection

        public void changeDirection​(com.badlogic.gdx.math.Vector2 newDir)
        Calculate velocity of the bullet (Translation per frame)
        Parameters:
        newDir - New direction of the bullet
      • update

        public void update()
        Description copied from class: GameObject
        Called every frame. Update the game object.
        Specified by:
        update in class GameObject
      • GetHitbox

        public com.badlogic.gdx.math.Circle GetHitbox()