LambdaHack-0.2.10: A roguelike game engine in early and active development

Safe HaskellNone

Game.LambdaHack.Common.Area

Description

Rectangular areas of levels and their basic operations.

Synopsis

Documentation

type Area = (X, Y, X, Y)

The type of areas. The bottom left and the top right points.

vicinityXY

Arguments

:: Area

limit the search to this area

-> PointXY

position to find neighbours of

-> [PointXY] 

All (8 at most) closest neighbours of a point within an area.

vicinityCardinalXY

Arguments

:: Area

limit the search to this area

-> PointXY

position to find neighbours of

-> [PointXY] 

All (4 at most) cardinal direction neighbours of a point within an area.

insideXY :: PointXY -> Area -> Bool

Checks that a point belongs to an area.

normalizeArea :: Area -> Area

Sort the corners of an area so that the bottom left is the first point.

grid :: (X, Y) -> Area -> [(PointXY, Area)]

Divide uniformly a larger area into the given number of smaller areas.

validArea :: Area -> Bool

Checks if it's an area with at least one field.

trivialArea :: Area -> Bool

Checks if it's an area with exactly one field.

expand :: Area -> Int -> Area

Enlarge (or shrink) the given area on all fours sides by the amount.