java.lang.Object
net.regsirius06.engine.core.graphics.minimap.MiniMap
All Implemented Interfaces:
Drawable2D

public class MiniMap extends Object implements 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 Details

    • MiniMap

      public MiniMap(@NotNull @NotNull Labyrinth2D labyrinth2D, int size, Player player)
      Constructs a new MiniMap instance with the specified labyrinth, size, and player.
      Parameters:
      labyrinth2D - the Labyrinth2D object representing the labyrinth
      size - the size of the minimap in pixels
      player - the Player object to be rendered on the minimap (can be null)
    • MiniMap

      public MiniMap(@NotNull @NotNull Labyrinth2D labyrinth2D, int size)
      Constructs a new MiniMap instance with the specified labyrinth and size. This version does not render the player.
      Parameters:
      labyrinth2D - the Labyrinth2D object representing the labyrinth
      size - the size of the minimap in pixels
  • Method Details

    • draw

      public final void draw(Graphics2D g2d)
      Draws the minimap onto the provided Graphics2D object. This method renders the labyrinth, light sources, and player (if available), as well as the border of the minimap.
      Specified by:
      draw in interface Drawable2D
      Parameters:
      g2d - the Graphics2D object to draw onto
    • renderMiniMap

      protected void renderMiniMap(Graphics2D g2d)
      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 - the Graphics2D object to draw onto
    • renderPlayer

      protected void renderPlayer(@NotNull @NotNull Graphics2D g2d, double playerX, double playerY)
      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 - the Graphics2D object to draw onto
      playerX - the x-coordinate of the player
      playerY - the y-coordinate of the player
    • renderBorder

      protected void renderBorder(@NotNull @NotNull Graphics2D g2d)
      Renders the border of the minimap. This method draws a white border around the minimap.
      Parameters:
      g2d - the Graphics2D object to draw onto