hfov-1.0.2: Field-of-view calculation for low-resolution 2D raster grids.

Safe HaskellNone

FOV

Description

HFOV is a library for calculating field of view in a 2D raster grid, such as those found in roguelike games.

Thanks to Greg McIntyre for the original C library to which this Haskell library binds. It can be found at http://libfov.sourceforge.net/wiki.

Synopsis

Documentation

data Settings Source

Opaque data structure for holding information about FOV calculation.

data Shape Source

Shape of the field.

Constructors

CirclePrecalculate

Limit the field of view to a circle radius R by precalculating the circle shape. This consumes memory at the rate of 4*(R+2) bytes per R used in calls to fovCircle. Each radius is only calculated once.

Circle

Limit the field to a circle shape calculated on the fly.

Octagon

Limit the field to an octagon with maximum radius R.

Square

Limit the field to an RxR square.

newSettings :: IO SettingsSource

Create a new FOV settings structure.

setShape :: Settings -> Shape -> IO ()Source

Set the shape of the field of view. The default is CirclePrecalculate.

setOpaqueApply :: Settings -> Bool -> IO ()Source

Sets whether or not to apply lighting to opaque squares.

circleSource

Arguments

:: Settings

The FOV settings structure to use

-> (Int, Int)

The centre of the field

-> Int

The radius

-> (Int -> Int -> IO ())

The function to be called in order to apply light to a certain position

-> (Int -> Int -> IO Bool)

The function to determine the opacity of a certain cell

-> IO () 

Cast a 360 degree field of view.

beamSource

Arguments

:: Settings

The FOV settings structure to use

-> (Int, Int)

Origin of the beam

-> Int

Length (radius) of the beam

-> Direction

Direction of the centre of the beam

-> Float

Width of the beam (in degrees)

-> (Int -> Int -> IO ())

Light application function

-> (Int -> Int -> IO Bool)

Opacity test function

-> IO () 

Cast a beam.