show fps
This commit is contained in:
parent
b7e0363647
commit
c469761bd8
3 changed files with 21 additions and 0 deletions
|
@ -55,6 +55,8 @@ load = do
|
||||||
mwalltsw <- createImage nvg (FileName "assets/walls/wall_t_sw.png") 0
|
mwalltsw <- createImage nvg (FileName "assets/walls/wall_t_sw.png") 0
|
||||||
mwalltnw <- createImage nvg (FileName "assets/walls/wall_t_nw.png") 0
|
mwalltnw <- createImage nvg (FileName "assets/walls/wall_t_nw.png") 0
|
||||||
mwallcross <- createImage nvg (FileName "assets/walls/wall_cross.png") 0
|
mwallcross <- createImage nvg (FileName "assets/walls/wall_cross.png") 0
|
||||||
|
_ <- createFont nvg "bedstead"
|
||||||
|
(FileName "assets/font/Bedstead-Semicondensed.ttf")
|
||||||
let mwalls = [ mwallasc, mwalldesc,
|
let mwalls = [ mwallasc, mwalldesc,
|
||||||
mwallcornern, mwallcornere, mwallcorners, mwallcornerw,
|
mwallcornern, mwallcornere, mwallcorners, mwallcornerw,
|
||||||
mwalltne, mwalltse, mwalltsw, mwalltnw,
|
mwalltne, mwalltse, mwalltsw, mwalltnw,
|
||||||
|
@ -68,6 +70,9 @@ load = do
|
||||||
, subsystems = subs
|
, subsystems = subs
|
||||||
, assetImages = M.fromList
|
, assetImages = M.fromList
|
||||||
walls
|
walls
|
||||||
|
, assetFonts = M.fromList
|
||||||
|
[ (FontBedstead, "bedstead")
|
||||||
|
]
|
||||||
, nano = nvg
|
, nano = nvg
|
||||||
, uuid = []
|
, uuid = []
|
||||||
, worldState = ws
|
, worldState = ws
|
||||||
|
|
10
src/Test.hs
10
src/Test.hs
|
@ -10,6 +10,8 @@ import Control.Monad (when, void)
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
|
|
||||||
import Data.Map.Strict as Map
|
import Data.Map.Strict as Map
|
||||||
|
import qualified Data.Set as S
|
||||||
|
import qualified Data.Text as T
|
||||||
import Data.Matrix as M (toLists, (!), Matrix, safeGet)
|
import Data.Matrix as M (toLists, (!), Matrix, safeGet)
|
||||||
import Data.Ecstasy as E
|
import Data.Ecstasy as E
|
||||||
|
|
||||||
|
@ -95,9 +97,17 @@ movePlayer _ = return ()
|
||||||
drawMap :: Affection UserData ()
|
drawMap :: Affection UserData ()
|
||||||
drawMap = do
|
drawMap = do
|
||||||
ud <- getAffection
|
ud <- getAffection
|
||||||
|
dt <- getDelta
|
||||||
let matrix = mapMat (stateData ud)
|
let matrix = mapMat (stateData ud)
|
||||||
mapM_ (\(i, ls) -> mapM_ (uncurry $ drawTile i) (reverse $ zip [1..] ls))
|
mapM_ (\(i, ls) -> mapM_ (uncurry $ drawTile i) (reverse $ zip [1..] ls))
|
||||||
(zip [1..] (toLists matrix))
|
(zip [1..] (toLists matrix))
|
||||||
|
liftIO $ do
|
||||||
|
let ctx = nano ud
|
||||||
|
fontSize ctx 20
|
||||||
|
fontFace ctx (assetFonts ud Map.! FontBedstead)
|
||||||
|
textAlign ctx (S.fromList [AlignCenter,AlignTop])
|
||||||
|
fillColor ctx (rgb 255 128 0)
|
||||||
|
textBox ctx 0 0 200 ("FPS: " `T.append` (T.pack $ Prelude.take 5 $ show (1/dt)))
|
||||||
|
|
||||||
updateMap :: Double -> Affection UserData ()
|
updateMap :: Double -> Affection UserData ()
|
||||||
updateMap dt = do
|
updateMap dt = do
|
||||||
|
|
|
@ -10,6 +10,7 @@ import Control.Concurrent.STM
|
||||||
import NanoVG hiding (V2(..), V3(..))
|
import NanoVG hiding (V2(..), V3(..))
|
||||||
|
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
|
import qualified Data.Text as T
|
||||||
import Data.Matrix
|
import Data.Matrix
|
||||||
import Data.Ecstasy
|
import Data.Ecstasy
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ data UserData = UserData
|
||||||
{ state :: State
|
{ state :: State
|
||||||
, subsystems :: Subsystems
|
, subsystems :: Subsystems
|
||||||
, assetImages :: M.Map ImgId Image
|
, assetImages :: M.Map ImgId Image
|
||||||
|
, assetFonts :: M.Map FontId T.Text
|
||||||
, nano :: Context
|
, nano :: Context
|
||||||
, uuid :: [UUID]
|
, uuid :: [UUID]
|
||||||
, worldState :: SystemState Entity
|
, worldState :: SystemState Entity
|
||||||
|
@ -50,6 +52,10 @@ data ImgId
|
||||||
| ImgWallCross
|
| ImgWallCross
|
||||||
deriving (Show, Eq, Ord, Enum)
|
deriving (Show, Eq, Ord, Enum)
|
||||||
|
|
||||||
|
data FontId
|
||||||
|
= FontBedstead
|
||||||
|
deriving (Show, Eq, Ord, Enum)
|
||||||
|
|
||||||
data Direction
|
data Direction
|
||||||
= N
|
= N
|
||||||
| W
|
| W
|
||||||
|
|
Loading…
Reference in a new issue