Package tdl :: Module map
[frames] | no frames]

Module map

source code

Rogue-like map utilitys such as line-of-sight, field-of-view, and path-finding.

Classes
  AStar
A* pathfinder
Functions
iterator
quickFOV(x, y, callback, fov='PERMISSIVE', radius=7.5, lightWalls=True, sphere=True)
All field-of-view functionality in one call.
source code
Function Details

quickFOV(x, y, callback, fov='PERMISSIVE', radius=7.5, lightWalls=True, sphere=True)

source code 

All field-of-view functionality in one call.

Before using this call be sure to make a function, lambda, or method that takes 2 positional parameters and returns True if light can pass the tile or False for light-blocking tiles and for positions that are out of bounds of the dungeon.

This function is 'quick' as in no hassle but can quickly become a very slow function call if a large radius is used or the callback provided itself isn't optimized.

Parameters:
  • x (int) - x center of the field-of-view
  • y (int) - y center of the field-of-view
  • callback (function) - This should be a function that takes two positional arguments x,y and returns True if the tile at that position is transparent or False if the tile blocks light or is out of bounds.
  • fov (string) - The type of field-of-view to be used. Available types are:

    'BASIC', 'DIAMOND', 'SHADOW', 'RESTRICTIVE', 'PERMISSIVE', 'PERMISSIVE0', 'PERMISSIVE1', ..., 'PERMISSIVE8'

  • radius (float) - Raduis of the field-of-view.

    When sphere is True a floating point can be used to fine-tune the range. Otherwise the radius is just rounded up.

    Be careful as a large radius has an exponential affect on how long this function takes.

  • lightWalls (boolean) - Include or exclude wall tiles in the field-of-view.
  • sphere (boolean) - True for a spherical field-of-view. False for a square one.
Returns: iterator
Returns an iterator of (x, y) points that are within the field-of-view