Class MiniMap
java.lang.Object
net.regsirius06.engine.core.graphics.minimap.MiniMap
- All Implemented Interfaces:
Drawable2D
Represents a 2D minimap of a labyrinth, displaying walls, light sources, and the player.
This class is responsible for rendering the minimap on a 2D Graphics context.
The minimap displays a small-scale view of the labyrinth, including walls, light sources, and the player's position. The rendering is scaled to fit within a specified size and is updated dynamically.
The minimap is displayed within a square area, with a scale factor based on the provided size. The player's position is marked with a red circle, and the walls are rendered using their respective colors. If light sources are present in the labyrinth, they are rendered as small circular highlights.
-
Constructor Summary
ConstructorsConstructorDescriptionMiniMap(@NotNull Labyrinth2D labyrinth2D, int size) Constructs a newMiniMapinstance with the specified labyrinth and size.MiniMap(@NotNull Labyrinth2D labyrinth2D, int size, Player player) Constructs a newMiniMapinstance with the specified labyrinth, size, and player. -
Method Summary
Modifier and TypeMethodDescriptionfinal voiddraw(Graphics2D g2d) Draws the minimap onto the providedGraphics2Dobject.protected voidrenderBorder(@NotNull Graphics2D g2d) Renders the border of the minimap.protected voidrenderMiniMap(Graphics2D g2d) Renders the labyrinth on the minimap.protected voidrenderPlayer(@NotNull Graphics2D g2d, double playerX, double playerY) Renders the player on the minimap at the specified coordinates.
-
Constructor Details
-
MiniMap
Constructs a newMiniMapinstance with the specified labyrinth, size, and player.- Parameters:
labyrinth2D- theLabyrinth2Dobject representing the labyrinthsize- the size of the minimap in pixelsplayer- thePlayerobject to be rendered on the minimap (can be null)
-
MiniMap
Constructs a newMiniMapinstance with the specified labyrinth and size. This version does not render the player.- Parameters:
labyrinth2D- theLabyrinth2Dobject representing the labyrinthsize- the size of the minimap in pixels
-
-
Method Details
-
draw
Draws the minimap onto the providedGraphics2Dobject. This method renders the labyrinth, light sources, and player (if available), as well as the border of the minimap.- Specified by:
drawin interfaceDrawable2D- Parameters:
g2d- theGraphics2Dobject to draw onto
-
renderMiniMap
Renders the labyrinth on the minimap. This method iterates through the labyrinth and fills the respective tiles with appropriate colors.It handles rendering the walls based on their state and color, and it highlights light sources using circular indicators.
- Parameters:
g2d- theGraphics2Dobject to draw onto
-
renderPlayer
Renders the player on the minimap at the specified coordinates. If the player is not null, this method will draw the player as a red circle.- Parameters:
g2d- theGraphics2Dobject to draw ontoplayerX- the x-coordinate of the playerplayerY- the y-coordinate of the player
-
renderBorder
Renders the border of the minimap. This method draws a white border around the minimap.- Parameters:
g2d- theGraphics2Dobject to draw onto
-