Class LabyrinthGraphics2D
java.lang.Object
net.regsirius06.engine.core.graphics.labyrinth.default2D.LabyrinthGraphics2D
- All Implemented Interfaces:
Drawable2D
The LabyrinthGraphics2D class provides the logic for rendering a 2D labyrinth with ray casting effects,
simulating what the player sees, including light sources, reflections, and walls.
This class visualizes the labyrinth and displays the player's perspective on the surrounding environment, taking into account factors such as lighting, intersections with objects, and reflections.
It implements the Drawable2D interface, which allows the labyrinth to be drawn on a 2D canvas.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleMovement step for rays during raycasting.static final doubleRotation step for rays (not used in current implementation). -
Constructor Summary
ConstructorsConstructorDescriptionLabyrinthGraphics2D(int width, int height, Labyrinth2D labyrinth, Player player) Constructor that initializes the LabyrinthGraphics2D instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected static doubleclaimAngle(double angle) Claims an angle by normalizing it to the range [0, 2ПЂ).final voiddraw(Graphics2D g2d) Draws the 2D visualization of the labyrinth and what the player sees.Returns the set of visible light sources.protected voidvisualize(Graphics2D g2d) Visualizes the labyrinth, including walls and light sources.
-
Field Details
-
moveStep
public static final double moveStepMovement step for rays during raycasting.- See Also:
-
rotationStep
public static final double rotationStepRotation step for rays (not used in current implementation).- See Also:
-
-
Constructor Details
-
LabyrinthGraphics2D
Constructor that initializes the LabyrinthGraphics2D instance.- Parameters:
width- The width of the canvas for rendering.height- The height of the canvas for rendering.labyrinth- The labyrinth instance representing the environment.player- The player instance determining the position and direction.
-
-
Method Details
-
getVisibleLightSources
Returns the set of visible light sources.- Returns:
- A set of light sources that are visible to the player.
-
draw
Draws the 2D visualization of the labyrinth and what the player sees.- Specified by:
drawin interfaceDrawable2D- Parameters:
g2d- The Graphics2D object used for drawing the scene.
-
visualize
Visualizes the labyrinth, including walls and light sources.- Parameters:
g2d- The Graphics2D object used for rendering the scene.
-
claimAngle
protected static double claimAngle(double angle) Claims an angle by normalizing it to the range [0, 2ПЂ).- Parameters:
angle- The angle to normalize.- Returns:
- The normalized angle in radians.
-