NAME

TCOD::Map - A grid of cells for field-of-view calculations

SYNOPSIS

use TCOD;

my $map = TCOD::Map->new( 10, 10 );

$map->set_properties( 6, 5, 0, 0 ); # Opaque cell
$map->compute_fov( 5, 5 );

$map->is_in_fov( 7, 5 );
# False: [ 6, 5 ] is opaque and obstructs the view from [ 5, 5 ]

DESCRIPTION

A TCOD::Map represents a grid of cells that can be used for pathfinding and field-of-view calculations.

METHODS

new

$map = TCOD::Map->new( $width, $height );

Construct a new TCOD::Map. Takes the width and height of the map in cells as positional arguments.

set_properties

$map->set_properties( $x, $y, $walkable, $transparent );

Set the properties of a cell in the map. Specifically, $walkable should be true if this cell does not obstruct the pathfinder, and $transparent should be true if this cell does not obstruct the field of vision algorithm.

clear

$map->clear( $walkable, $transparent );

Resets all of a map's cells to have the specified attributes.

copy

$source->copy( $destination );

Copy the cells of one map into another. The destination map should be at least large enough to hold the source map.

compute_fov

$map->compute_fov( $x, $y, $radius, $light_walls, $algorithm );

Compute the field of view from the specified cell. The value in the $radius parameter will determine how far to extend the line of sight, while the value in $light_walls will determine whether walls adjacent to visible cells should themselves be visible.

The value in $algorithm should be one of the values in the FOV enum. If no value is set, it will default to TCOD::FOV_BASIC.

is_in_fov

$bool = $map->is_in_fov( $x, $y );

After computing the field of view for this map, this method queries whether a particular cell is visible or not.

is_transparent

$bool = $map->is_transparent( $x, $y );

Returns true if the specified cell has the attribute transparent set to a true value.

is_walkable

$bool = $map->is_walkable( $x, $y );

Returns true if the specified cell has the attribute walkable set to a true value.

get_width

$width = $map->get_width;

Returns the width of the map in cells. This is the same value used during object construction.

get_height

$height = $map->get_height;

Returns the height of the map in cells. This is the same value used during object construction.

SEE ALSO

TCOD
TCOD::Path
TCOD::Dijkstra

COPYRIGHT AND LICENSE

Copyright 2021 José Joaquín Atria

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.