NAME

Term::Maze - Mazes in the terminal

VERSION

Version 0.04

SYNOPSIS

use Term::Maze;

Term::Maze->run(40, 20);

...

#########################################
#S#   #   #       #               #     #
# # # ### # # ### ####### ####### # # # #
# # # #   # #   #       #       #   # # #
# # # # ### ### ####### ### ######### # #
# # # # #   # #       #   # #   #     # #
# # # # # ### ####### ### ### # # ##### #
# # # #         #     #   #   # # # #   #
# # # ####### ### ##### ### ### # # # ###
#   #     #   #   # #   #   #     # #   #
######### # ### ### # ### ######### ### #
#         #   #  @# #   #     #     #   #
# ########### ### # ### ### # # # ### ###
#   #         # # #       # # # #   # # #
### # ######### # ####### # # ##### # # #
#   #           # #     # # #   #   #   #
# ############# # # ### # ##### # ##### #
#             # #     # #     # #   #   #
############# ######### ##### # # # # ###
#                       #       # #    E#
#########################################
Use WASD to move. Reach the exit to win.

SUBROUTINES/METHODS

run

Runs the maze game. It initializes the maze with the specified width and height, sets the terminal to cbreak mode, and starts the game loop where the player can move using WASD keys.

Term::Maze->run(40, 20);

refresh

Refreshes the maze display in the terminal. It clears the screen, retrieves the maze with the player's position, and prints it to the terminal.

$maze->refresh();

new

Instantiate a new Term::Maze object with the specified width and height. This method initializes the maze structure, player position, and exit point.

my $maze = Term::Maze->new($width, $height);

move_player

Moves the player in the maze based on the input key. The player can move up, down, left, or right using the WASD keys. It checks for valid moves and updates the player's position accordingly.

$maze->move_player('w'); # Move up
$maze->move_player('a'); # Move left
$maze->move_player('s'); # Move down
$maze->move_player('d'); # Move right

get_maze_with_player

Returns the maze structure with the player's current position. It generates a 2D array representation of the maze, including walls, paths, the player, and the exit.

my $rows = $maze->get_maze_with_player();

at_exit

Checks if the player has reached the exit point in the maze. It compares the player's current position with the exit coordinates.

my $at_exit = $maze->at_exit;

AUTHOR

LNATION, <email at lnation.org>

BUGS

Please report any bugs or feature requests to bug-term-maze at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Term-Maze. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Term::Maze

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2025 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)