module Game.LambdaHack.VectorXY
( VectorXY(..), shiftXY, movesXY, movesCardinalXY
, chessDistXY, euclidDistSqXY, negXY
) where
import Game.LambdaHack.PointXY
newtype VectorXY = VectorXY (X, Y)
deriving (Show, Eq)
shiftXY :: PointXY -> VectorXY -> PointXY
shiftXY (PointXY (x0, y0)) (VectorXY (x1, y1)) = PointXY (x0 + x1, y0 + y1)
movesXY :: [VectorXY]
movesXY =
map VectorXY
[(1, 1), (0, 1), (1, 1), (1, 0), (1, 1), (0, 1), (1, 1), (1, 0)]
movesCardinalXY :: [VectorXY]
movesCardinalXY = map VectorXY [(0, 1), (1, 0), (0, 1), (1, 0)]
chessDistXY :: VectorXY -> Int
chessDistXY (VectorXY (x, y)) = max (abs x) (abs y)
euclidDistSqXY :: VectorXY -> Int
euclidDistSqXY (VectorXY (x, y)) = x * x + y * y
negXY :: VectorXY -> VectorXY
negXY (VectorXY (x, y)) = VectorXY (x, y)