Class BulletUtil

java.lang.Object
util.BulletUtil

public class BulletUtil extends Object
Utility class for handling bullet interactions in the game. Used in Room.

Provides methods to check collisions between bullets and characters and filter out bullets that should no longer exist.

  • Constructor Details

    • BulletUtil

      public BulletUtil()
  • Method Details

    • shouldBulletStayAlive

      public static boolean shouldBulletStayAlive(Bullet b, List<Character> characters)
      Determines whether a bullet should continue existing or be removed based on collisions with characters.
      Parameters:
      b - the bullet to check
      characters - the list of characters to check collisions against
      Returns:
      true if the bullet should stay alive, false if it hit a character
    • filterAliveBullets

      public static void filterAliveBullets(List<Bullet> bullets, List<Character> characters)
      Filters the given list of bullets, removing bullets that have collided with characters and should no longer exist.
      Parameters:
      bullets - the list of bullets to filter
      characters - the list of characters to check collisions against