Package model.utilz
Interface HelpMethods
public interface HelpMethods
Provides helper methods for various game-related calculations and checks.
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic booleanCanMoveHere(float x, float y, float width, float height, int[][] levelData) Checks if the entity can move to the specified position.static floatGetEntityYPosAboveFloor(Rectangle2D.Float hitbox, float airSpeed, int[][] levelData) Returns the y-coordinate position of the entity above the floor.static PointGetRandomPosition(int[][] levelData, Rectangle hitbox) Returns a random position in the level where the hitbox is not colliding with a solid tile.static booleanIsEntityInsideMap(Rectangle2D.Float hitbox) Checks if the specified hitbox is inside the map boundaries.static booleanIsEntityInsideSolid(Rectangle2D.Float hitbox, int[][] levelData) Checks if the specified hitbox is inside a solid tile.static booleanIsEntityOnFloor(Rectangle2D.Float hitbox, int[][] lvlData) Checks if the entity is on the floor.static booleanIsPerimeterWallTile(float x) Checks if the specified x-coordinate is within a perimeter wall tile.static booleanIsSolid(float x, float y, int[][] lvlData) Checks if the specified coordinates are within a solid tile.static booleanIsTileInsideMap(int xTile, int yTile) Checks if the specified tile is inside the map boundaries.static booleanIsTilePerimeterWall(int xTile) Checks if the specified tile is a perimeter wall tile.static booleanIsTileRoof(int yTile) Checks if the specified tile is a roof tile.static booleanIsTileSolid(int xTile, int yTile, int[][] levelData) Checks if the specified tile is solid.static booleanIsWall(int xTile, int yTile, int[][] levelData) Checks if the specified tile is a wall.static floatYAxisDistanceToFirstSolid(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 tileyTile- the y-coordinate of the tilelevelData- 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 tileyTile- 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 tileyTile- the y-coordinate of the tilelevelData- 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-coordinatey- the y-coordinatelvlData- the level data array- Returns:
- true if the coordinates are within a solid tile, false otherwise
-
IsEntityInsideMap
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
Checks if the specified hitbox is inside a solid tile.- Parameters:
hitbox- the hitbox of the entitylevelData- 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 positiony- the y-coordinate of the positionwidth- the width of the entityheight- the height of the entitylevelData- the level data array- Returns:
- true if the entity can move to the position, false otherwise
-
GetEntityYPosAboveFloor
Returns the y-coordinate position of the entity above the floor.- Parameters:
hitbox- the hitbox of the entityairSpeed- the air speed of the entitylevelData- 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-coordinateyEnd- the ending y-coordinatex- the x-coordinatelvlData- the level data array- Returns:
- the distance to the first solid tile
-
IsEntityOnFloor
Checks if the entity is on the floor.- Parameters:
hitbox- the hitbox of the entitylvlData- the level data array- Returns:
- true if the entity is on the floor, false otherwise
-
GetRandomPosition
Returns a random position in the level where the hitbox is not colliding with a solid tile.- Parameters:
levelData- the level data arrayhitbox- the hitbox of the entity- Returns:
- a random position in the level
-