Package model.utilz

Interface HelpMethods


public interface HelpMethods
Provides helper methods for various game-related calculations and checks.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static boolean
    CanMoveHere(float x, float y, float width, float height, int[][] levelData)
    Checks if the entity can move to the specified position.
    static float
    GetEntityYPosAboveFloor(Rectangle2D.Float hitbox, float airSpeed, int[][] levelData)
    Returns the y-coordinate position of the entity above the floor.
    static Point
    GetRandomPosition(int[][] levelData, Rectangle hitbox)
    Returns a random position in the level where the hitbox is not colliding with a solid tile.
    static boolean
    Checks if the specified hitbox is inside the map boundaries.
    static boolean
    IsEntityInsideSolid(Rectangle2D.Float hitbox, int[][] levelData)
    Checks if the specified hitbox is inside a solid tile.
    static boolean
    IsEntityOnFloor(Rectangle2D.Float hitbox, int[][] lvlData)
    Checks if the entity is on the floor.
    static boolean
    Checks if the specified x-coordinate is within a perimeter wall tile.
    static boolean
    IsSolid(float x, float y, int[][] lvlData)
    Checks if the specified coordinates are within a solid tile.
    static boolean
    IsTileInsideMap(int xTile, int yTile)
    Checks if the specified tile is inside the map boundaries.
    static boolean
    Checks if the specified tile is a perimeter wall tile.
    static boolean
    IsTileRoof(int yTile)
    Checks if the specified tile is a roof tile.
    static boolean
    IsTileSolid(int xTile, int yTile, int[][] levelData)
    Checks if the specified tile is solid.
    static boolean
    IsWall(int xTile, int yTile, int[][] levelData)
    Checks if the specified tile is a wall.
    static float
    YAxisDistanceToFirstSolid(int yStart, int yEnd, int x, int[][] lvlData)
    Returns the distance to the first solid tile along the y-axis.
  • Method Details

    • IsTileRoof

      static boolean IsTileRoof(int yTile)
      Checks if the specified tile is a roof tile.
      Parameters:
      yTile - the y-coordinate of the tile
      Returns:
      true if the tile is a roof tile, false otherwise
    • IsWall

      static boolean IsWall(int xTile, int yTile, int[][] levelData)
      Checks if the specified tile is a wall.
      Parameters:
      xTile - the x-coordinate of the tile
      yTile - the y-coordinate of the tile
      levelData - the level data array
      Returns:
      true if the tile is a wall, false otherwise
    • IsTilePerimeterWall

      static boolean IsTilePerimeterWall(int xTile)
      Checks if the specified tile is a perimeter wall tile.
      Parameters:
      xTile - the x-coordinate of the tile
      Returns:
      true if the tile is a perimeter wall tile, false otherwise
    • IsPerimeterWallTile

      static boolean IsPerimeterWallTile(float x)
      Checks if the specified x-coordinate is within a perimeter wall tile.
      Parameters:
      x - the x-coordinate
      Returns:
      true if the x-coordinate is within a perimeter wall tile, false otherwise
    • IsTileInsideMap

      static boolean IsTileInsideMap(int xTile, int yTile)
      Checks if the specified tile is inside the map boundaries.
      Parameters:
      xTile - the x-coordinate of the tile
      yTile - the y-coordinate of the tile
      Returns:
      true if the tile is inside the map boundaries, false otherwise
    • IsTileSolid

      static boolean IsTileSolid(int xTile, int yTile, int[][] levelData)
      Checks if the specified tile is solid.
      Parameters:
      xTile - the x-coordinate of the tile
      yTile - the y-coordinate of the tile
      levelData - the level data array
      Returns:
      true if the tile is solid, false otherwise
    • IsSolid

      static boolean IsSolid(float x, float y, int[][] lvlData)
      Checks if the specified coordinates are within a solid tile.
      Parameters:
      x - the x-coordinate
      y - the y-coordinate
      lvlData - the level data array
      Returns:
      true if the coordinates are within a solid tile, false otherwise
    • IsEntityInsideMap

      static boolean IsEntityInsideMap(Rectangle2D.Float hitbox)
      Checks if the specified hitbox is inside the map boundaries.
      Parameters:
      hitbox - the hitbox of the entity
      Returns:
      true if the hitbox is inside the map boundaries, false otherwise
    • IsEntityInsideSolid

      static boolean IsEntityInsideSolid(Rectangle2D.Float hitbox, int[][] levelData)
      Checks if the specified hitbox is inside a solid tile.
      Parameters:
      hitbox - the hitbox of the entity
      levelData - the level data array
      Returns:
      true if the hitbox is inside a solid tile, false otherwise
    • CanMoveHere

      static boolean CanMoveHere(float x, float y, float width, float height, int[][] levelData)
      Checks if the entity can move to the specified position.
      Parameters:
      x - the x-coordinate of the position
      y - the y-coordinate of the position
      width - the width of the entity
      height - the height of the entity
      levelData - the level data array
      Returns:
      true if the entity can move to the position, false otherwise
    • GetEntityYPosAboveFloor

      static float GetEntityYPosAboveFloor(Rectangle2D.Float hitbox, float airSpeed, int[][] levelData)
      Returns the y-coordinate position of the entity above the floor.
      Parameters:
      hitbox - the hitbox of the entity
      airSpeed - the air speed of the entity
      levelData - the level data array
      Returns:
      the y-coordinate position above the floor
    • YAxisDistanceToFirstSolid

      static float YAxisDistanceToFirstSolid(int yStart, int yEnd, int x, int[][] lvlData)
      Returns the distance to the first solid tile along the y-axis.
      Parameters:
      yStart - the starting y-coordinate
      yEnd - the ending y-coordinate
      x - the x-coordinate
      lvlData - the level data array
      Returns:
      the distance to the first solid tile
    • IsEntityOnFloor

      static boolean IsEntityOnFloor(Rectangle2D.Float hitbox, int[][] lvlData)
      Checks if the entity is on the floor.
      Parameters:
      hitbox - the hitbox of the entity
      lvlData - the level data array
      Returns:
      true if the entity is on the floor, false otherwise
    • GetRandomPosition

      static Point GetRandomPosition(int[][] levelData, Rectangle hitbox)
      Returns a random position in the level where the hitbox is not colliding with a solid tile.
      Parameters:
      levelData - the level data array
      hitbox - the hitbox of the entity
      Returns:
      a random position in the level