haskelloids/src/Main.hs
2017-02-20 20:21:06 +01:00

57 lines
1.1 KiB
Haskell

{-# LANGUAGE OverloadedStrings #-}
module Main where
import Affection
import qualified SDL
import GEGL
import Data.List (delete)
import qualified Data.Map as M
import Data.Maybe (catMaybes)
import Control.Monad (when, foldM)
import Debug.Trace
-- internal imports
import Types
import Commons
import StateMachine
import Menu
import InGame
main :: IO ()
main = withAffection AffectionConfig
{ initComponents = All
, windowTitle = "Haskelloids"
, windowConfig = defaultWindow
, preLoop = pre
, drawLoop = draw
, updateLoop = update
, loadState = load
, cleanUp = clean
}
pre :: Affection UserData ()
pre = do
smLoad Menu
-- ud <- getAffection
-- liftIO $ gegl_node_process (nodeGraph ud M.! KeySink)
-- present
-- (GeglRectangle 0 0 800 600)
-- (buffer ud)
-- True
update :: Double -> [SDL.Event] -> Affection UserData ()
update sec evs = do
wd <- getAffection
smUpdate (state wd) sec
mapM_ (smEvent (state wd) sec) evs
draw :: Affection UserData ()
draw = do
ud <- getAffection
smDraw $ state ud