Safe Haskell | None |
---|
Basic operations on 2D points represented as linear offsets.
- type X = Int
- type Y = Int
- data Point = Point {}
- maxLevelDimExponent :: Int
- chessDist :: Point -> Point -> Int
- euclidDistSq :: Point -> Point -> Int
- adjacent :: Point -> Point -> Bool
- inside :: Point -> (X, Y, X, Y) -> Bool
- bla :: X -> Y -> Int -> Point -> Point -> Maybe [Point]
- fromTo :: Point -> Point -> [Point]
Documentation
2D points in cartesian representation. Coordinates grow to the right and down, so that the (0, 0) point is in the top-left corner of the screen. Coordinates are never negative.
maxLevelDimExponent :: IntSource
The maximum number of bits for level X and Y dimension (16). The value is chosen to support architectures with 32-bit Ints.
euclidDistSq :: Point -> Point -> IntSource
Squared euclidean distance between two points.
adjacent :: Point -> Point -> BoolSource
Checks whether two points are adjacent on the map (horizontally, vertically or diagonally).
bla :: X -> Y -> Int -> Point -> Point -> Maybe [Point]Source
Bresenham's line algorithm generalized to arbitrary starting eps
(eps
value of 0 gives the standard BLA).
Skips the source point and goes through the second point
to the edge of the level. GIves Nothing
if the points are equal.
The target is given as Point
to permit aiming out of the level,
e.g., to get uniform distributions of directions for explosions
close to the edge of the level.