Add tilemap floors to rooms

This commit is contained in:
2021-06-15 14:56:32 +02:00
parent 73bd407c49
commit da631e3b37
31 changed files with 181 additions and 66 deletions
+31
View File
@@ -0,0 +1,31 @@
module Tile
where
import Data.Tile
import Geometry
import Geometry.Data
import Picture.Data
tToRender :: Tile -> [RenderType]
tToRender t = map Render3x3 $ polyToTris $ zip ps3 coords3
where
ps = _tilePoly t
coords = map (calcTexCoord (_tileCenter t) (_tileX t) (_tileY t)) ps
ps3 = map (mkTrip (0.9)) ps
coords3 = map (mkTrip (_tileZ t)) coords
mkTrip :: c -> (a,b) -> (a,b,c)
mkTrip z (x,y) = (x,y,z)
calcTexCoord
:: Point2 -- ^ tile (0,0)
-> Point2 -- ^ tile (1,0)
-> Point2 -- ^ tile (0,1)
-> Point2 -- ^ world point
-> Point2
calcTexCoord cen x' y' p =
( magV (projV (p -.- cen) x) / magV x
, magV (projV (p -.- cen) y) / magV y
)
where
x = x' -.- cen
y = y' -.- cen