LambdaHack-0.8.3.0: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe HaskellNone
LanguageHaskell2010

Game.LambdaHack.Common.Point

Contents

Description

Basic operations on 2D points represented as linear offsets.

Synopsis

Documentation

type X = Int #

Spacial dimension for points and vectors.

type Y = Int #

Spacial dimension for points and vectors.

data Point #

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.

Constructors

Point 

Fields

Instances
Enum Point # 
Instance details

Defined in Game.LambdaHack.Common.Point

Eq Point # 
Instance details

Defined in Game.LambdaHack.Common.Point

Methods

(==) :: Point -> Point -> Bool #

(/=) :: Point -> Point -> Bool #

Ord Point # 
Instance details

Defined in Game.LambdaHack.Common.Point

Methods

compare :: Point -> Point -> Ordering #

(<) :: Point -> Point -> Bool #

(<=) :: Point -> Point -> Bool #

(>) :: Point -> Point -> Bool #

(>=) :: Point -> Point -> Bool #

max :: Point -> Point -> Point #

min :: Point -> Point -> Point #

Show Point # 
Instance details

Defined in Game.LambdaHack.Common.Point

Methods

showsPrec :: Int -> Point -> ShowS #

show :: Point -> String #

showList :: [Point] -> ShowS #

Generic Point # 
Instance details

Defined in Game.LambdaHack.Common.Point

Associated Types

type Rep Point :: * -> * #

Methods

from :: Point -> Rep Point x #

to :: Rep Point x -> Point #

Binary Point # 
Instance details

Defined in Game.LambdaHack.Common.Point

Methods

put :: Point -> Put #

get :: Get Point #

putList :: [Point] -> Put #

type Rep Point # 
Instance details

Defined in Game.LambdaHack.Common.Point

type Rep Point = D1 (MetaData "Point" "Game.LambdaHack.Common.Point" "LambdaHack-0.8.3.0-1hn0NFDS4ux6qD3ggO7yse" False) (C1 (MetaCons "Point" PrefixI True) (S1 (MetaSel (Just "px") NoSourceUnpackedness NoSourceStrictness DecidedStrict) (Rec0 X) :*: S1 (MetaSel (Just "py") NoSourceUnpackedness NoSourceStrictness DecidedStrict) (Rec0 Y)))

maxLevelDimExponent :: Int #

The maximum number of bits for level X and Y dimension (16). The value is chosen to support architectures with 32-bit Ints.

chessDist :: Point -> Point -> Int #

The distance between two points in the chessboard metric.

euclidDistSq :: Point -> Point -> Int #

Squared euclidean distance between two points.

adjacent :: Point -> Point -> Bool #

Checks whether two points are adjacent on the map (horizontally, vertically or diagonally).

inside :: Point -> (X, Y, X, Y) -> Bool #

Checks that a point belongs to an area.

bla :: X -> Y -> Int -> Point -> Point -> Maybe [Point] #

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.

fromTo :: Point -> Point -> [Point] #

A list of all points on a straight vertical or straight horizontal line between two points. Fails if no such line exists.

Internal operations

maxLevelDim :: Int #

Maximal supported level X and Y dimension. Not checked anywhere. The value is chosen to support architectures with 32-bit Ints.

blaXY :: Int -> Point -> Point -> [Point] #

Bresenham's line algorithm generalized to arbitrary starting eps (eps value of 0 gives the standard BLA). Includes the source point and goes through the target point to infinity.