Safe Haskell | None |
---|
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.
- data Settings
- data Shape
- = CirclePrecalculate
- | Circle
- | Octagon
- | Square
- data Direction
- newSettings :: IO Settings
- setShape :: Settings -> Shape -> IO ()
- setOpaqueApply :: Settings -> Bool -> IO ()
- circle :: Settings -> (Int, Int) -> Int -> (Int -> Int -> IO ()) -> (Int -> Int -> IO Bool) -> IO ()
- beam :: Settings -> (Int, Int) -> Int -> Direction -> Float -> (Int -> Int -> IO ()) -> (Int -> Int -> IO Bool) -> IO ()
Documentation
Shape of the field.
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.
:: 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.
:: 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.