darcsden :: RylandAlmanza -> AtomicRogue -> blob

An attempt at making a fully featured roguelike where all objects are represented as single pixels

root / Tile.hs

module Tile
( Tile(..)
, drawTile
, createCaveFloorTile
, createCaveWallTile
) where

import Data.Word
import Graphics.UI.SDL as SDL
import PixelManipulation

data Tile = Tile
    { tileX :: Int
    , tileY :: Int
    , tileRed :: Word8
    , tileGreen :: Word8
    , tileBlue :: Word8
    , tileIsWalkable :: Bool
    , tileIsTransparent :: Bool
    } deriving (Show)

createCaveFloorTile :: Int -> Int -> Tile
createCaveFloorTile x y = Tile
    { tileX = x
    , tileY = y
    , tileRed = 115
    , tileGreen = 111
    , tileBlue = 110
    , tileIsWalkable = True
    , tileIsTransparent = True
    }

createCaveWallTile :: Int -> Int -> Tile
createCaveWallTile x y = Tile
    { tileX = x
    , tileY = y
    , tileRed = 0
    , tileGreen = 0
    , tileBlue = 0
    , tileIsWalkable = False
    , tileIsTransparent = False
    }

drawTile t s = do
    pixel <- mapRGB (surfaceGetPixelFormat s) (tileRed t) (tileGreen t) (tileBlue t)
    putPixel32 (tileX t) (tileY t) pixel s