tcod-haskell-0.1.0.0: Bindings to libtcod roguelike engine

Safe HaskellNone
LanguageHaskell2010

Game.TCOD.Bresenham

Description

This toolkit is a very simple and lightweight implementation of the bresenham line drawing algorithm. It allows you to follow straight paths on your map very easily.

Synopsis

Documentation

type TCODLineListener = Int -> Int -> IO Bool Source #

Takes x y of point and tells when to stop

lineInitGlobal Source #

Arguments

:: Int

x from

-> Int

y from

-> Int

x to

-> Int

y to

-> IO () 

Initializing the line

First, you have to initialize the toolkit with your starting and ending coordinates.

lineStepGlobal :: IO (Bool, Int, Int) Source #

Walking the line

You can then step through each cell with this function. It returns true when you reach the line's ending point.

lineGlobal Source #

Arguments

:: Int

x from

-> Int

y from

-> Int

x to

-> Int

y to

-> TCODLineListener

Callback called for each line's point. The function stops if the callback returns false.

-> IO Bool 

Callback-based function. Stops when the callback returns false

The function returns false if the line has been interrupted by the callback (it returned false before the last point).

data TCODBresenhamData Source #

Holds state of Bresenham algorithm for thread safe version of API

Instances

Eq TCODBresenhamData Source # 
Show TCODBresenhamData Source # 
Generic TCODBresenhamData Source # 
Storable TCODBresenhamData Source # 
type Rep TCODBresenhamData Source # 

lineInit Source #

Arguments

:: Int

x from

-> Int

y from

-> Int

x to

-> Int

y to

-> TCODBresenhamData

State of algorithm that is passed around

Initializing the line, thread safe version

First, you have to initialize the toolkit with your starting and ending coordinates.

lineStep :: TCODBresenhamData -> (TCODBresenhamData, Bool, Int, Int) Source #

Walking the line, thread safe version

You can then step through each cell with this function. It returns true when you reach the line's ending point.

lineIO Source #

Arguments

:: Int

x from

-> Int

y from

-> Int

x to

-> Int

y to

-> TCODLineListener

Callback called for each line's point. The function stops if the callback returns false.

-> IO Bool 

Callback-based function. Stops when the callback returns false, thread safe version

The function returns false if the line has been interrupted by the callback (it returned false before the last point).

line Source #

Arguments

:: Int

x from

-> Int

y from

-> Int

x to

-> Int

y to

-> (Int -> Int -> Bool)

Callback called for each line's point. The function stops if the callback returns false.

-> Bool 

Callback-based function. Stops when the callback returns false, thread safe version

The function returns false if the line has been interrupted by the callback (it returned false before the last point).

Note: that predicated is pure unlike in lineIO