From ce13d7eaa45b59647325b97e40906c54dbcf4b38 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Thu, 23 Feb 2023 12:21:24 +0000 Subject: Bitmap font --- src/Game.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Game.hs') diff --git a/src/Game.hs b/src/Game.hs index 1e0245b..53be0ad 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -5,6 +5,7 @@ import Data.IORef import Data.Maybe (fromMaybe) import Data.Text (pack) import Foreign.C.Types (CInt) +import qualified Game.BitmapFont as BF import qualified Game.Controller as C import qualified Game.Entities as E import qualified Game.Hud as H @@ -44,6 +45,7 @@ data Env = Env controls :: IORef C.Controls, map :: M.Map, sprites :: S.SpriteSheet, + font :: BF.BitmapFont, entities :: IORef E.Entities, hud :: H.Hud, state :: IORef GS.State @@ -73,9 +75,11 @@ main = do renderRect <- newIORef defaultRenderRect tsTexture <- SDL.Image.loadTexture renderer "data/tiles.png" ssTexture <- SDL.Image.loadTexture renderer "data/sprites.png" + bfTexture <- SDL.Image.loadTexture renderer "data/font.png" controls <- newIORef =<< C.init map' <- M.load "data/map.json" tsTexture sprites <- S.load "data/sprites.json" ssTexture + font <- BF.load "data/font.json" bfTexture state <- newIORef GS.State @@ -98,6 +102,7 @@ main = do controls = controls, map = map', sprites = sprites, + font = font, entities = entities, hud = hud, state = state @@ -140,6 +145,7 @@ gameLoop = do map' = env.map entities = env.entities hud = env.hud + font = env.font events <- map SDL.eventPayload <$> SDL.pollEvents @@ -163,6 +169,7 @@ gameLoop = do M.render renderer map' H.render renderer hud E.render renderer updated + BF.renderText renderer font 120 178 "This is a test!" SDL.rendererRenderTarget renderer $= Nothing SDL.clear renderer -- cgit v1.2.3