{-| TileEngine is a multi-layered tile-map engine for the creation of games using Haskell's SDL2 library . Setup: Before jumping into writing code, there are a few pre-requisite. First and most obvious, you will need to install SDL2 on your machine. We will not go deep into the installation process here, as there are many examples such as Lazy Foo' excellent installation guide . By default, SDL2 supports BMP files. To use PNG files and take advantage of transparency in tiles, install SDL2 Image extension . Once SDL2 is on your machine, it is time to install the necessary SDL2 wrappers for Haskell . Make sure to also install SDL2 Image wrapper . Getting Started: Import the TileEngine library. @ import qualified TileEngine @ The first step in creating a tile-based map is to create an Image for our Tileset. An Image is composed of an image texture and the dimension of that image texture. SDL2 provides functions that facilitate the creation of an image texture from a file path and obtaining the dimension of that texture. Below is an example function that completes the process of creating an Image. @ createImage :: SDL.Renderer -> String -> IO TileEngine.Image createImage renderer path = do surface <- SDL.Image.load path size <- SDL.surfaceDimensions surface let key = V4 0 maxBound maxBound maxBound SDL.surfaceColorKey surface $= Just key texture <- SDL.createTextureFromSurface renderer surface SDL.freeSurface surface return $ TileEngine.Image texture size @ The Image can then be passed to the `TileEngine.tileset` function to create a Tileset. @ timage <- createImage "img/tilesheet.png" let tileset = TileEngine.tileset (70, 70) (2, 2) timage @ Layers: There are two ways to create a layer. The easiest is to use the `TileEngine.fromCSV` function. The function allows you to import your standard comma-separated map layers exported from popular tile map editors like Tiled. @ layer <- TileEngine.fromCSV (20, 15) tileset "map/layer01.csv" @ If you would like to pre-process your map layers, the `TileEngine.layer` method allows you create a layer by manually passing a list of Ints. @ let layer = TileEngine.layer (20, 15) tileset vals @ To render a layer, use the `TileEngine.renderLayer` method. In addition to the layer that will be rendered, a coordinate is passed corresponding to the top-left offset of the layer. Change this value to scroll the layer. @ renderLayer renderer (0,0) layer @ Dive Deeper: Examples can be found by visiting the project's github page -} module TileEngine ( module TileEngine , module TileEngine.Tileset , module TileEngine.Tile , module TileEngine.Layer , module TileEngine.Shared ) where import TileEngine.Shared ( Image(Image), imageTexture, imageSize) import TileEngine.Tileset ( Tileset(Tileset), tilesetImage, tileSize, tilesetSpacing, tileClips, tileset) import TileEngine.Layer ( Layer( TileLayer, EventLayer ), layerTileset, layerDimension, layerTiles, layerTileDimension, renderLayer, fromCSV, eventLayer, layer, layerValue, layerPValue) import TileEngine.Tile ( Tile( SurfaceTile, EventTile ), tileImgRect, tileRect, tileValue) import qualified SDL