From 73a52e531d940858f0ac334d8b2ccda479ea7b5e Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Mon, 2 Sep 2019 14:45:36 -0400 Subject: Put a test gormlak on the screen Implement a concrete "Creature" entity, and place one on the screen at the game startup for testing. This revealed a bug with drawing when getting the maximum entity position, but that appears to be fixed now (yay) --- src/Xanthous/App.hs | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'src/Xanthous/App.hs') diff --git a/src/Xanthous/App.hs b/src/Xanthous/App.hs index 3561d35a3bb2..6cf22135a7a4 100644 --- a/src/Xanthous/App.hs +++ b/src/Xanthous/App.hs @@ -1,18 +1,25 @@ module Xanthous.App (makeApp) where -import Xanthous.Prelude -import Brick hiding (App, halt, continue) +import Xanthous.Prelude +import Brick hiding (App, halt, continue, raw) import qualified Brick -import Graphics.Vty.Attributes (defAttr) -import Graphics.Vty.Input.Events (Event(EvKey)) -import Control.Monad.State (get) +import Graphics.Vty.Attributes (defAttr) +import Graphics.Vty.Input.Events (Event(EvKey)) +import Control.Monad.State (get) -import Xanthous.Game -import Xanthous.Game.Draw (drawGame) -import Xanthous.Resource (Name) -import Xanthous.Command -import Xanthous.Data (move) -import Xanthous.Monad +import Xanthous.Command +import Xanthous.Data (move, Position(..)) +import qualified Xanthous.Data.EntityMap as EntityMap +import Xanthous.Game +import Xanthous.Game.Draw (drawGame) +import Xanthous.Monad +import Xanthous.Resource (Name) + +import Xanthous.Entities.Creature (Creature) +import qualified Xanthous.Entities.Creature as Creature +import Xanthous.Entities.RawTypes (EntityRaw(..)) +import Xanthous.Entities.Raws (raw) +import Xanthous.Entities.SomeEntity type App = Brick.App GameState () Name type AppM a = AppT (EventM Name) a @@ -29,8 +36,15 @@ makeApp = pure $ Brick.App runAppM :: AppM a -> GameState -> EventM Name a runAppM appm = fmap fst . runAppT appm +testGormlak :: Creature +testGormlak = + let Just (Creature gormlak) = raw "gormlak" + in Creature.newWithType gormlak + startEvent :: AppM () -startEvent = say ["welcome"] +startEvent = do + () <- say ["welcome"] + entities %= EntityMap.insertAt (Position 10 10) (SomeEntity testGormlak) handleEvent :: BrickEvent Name () -> AppM (Next GameState) handleEvent (VtyEvent (EvKey k mods)) -- cgit 1.4.1