small platformer game
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

39 lines
963 B

{-# LANGUAGE OverloadedStrings #-}
module State.MainGame.Load where
import Affection
import Control.Concurrent (forkIO)
import Control.Concurrent.STM
import Control.Monad (void)
-- internal imports
import Types
import Map
mainGameLoad
:: GameData
-> Affection ()
mainGameLoad gd = do
liftIO $ atomically $ do
_ <- takeTMVar (gameStateLoadProgress gd)
putTMVar (gameStateLoadProgress gd) (0, "Ohai!")
liftIO $ logIO Verbose "Entering main Game"
liftIO $ void $ forkIO $ loadFork (gameStateData gd) (gameStateLoadProgress gd)
loadFork
:: TMVar StateData
-> TMVar Progress
-> IO ()
loadFork dataContainer progress = do
atomically $ do
_ <- takeTMVar progress
putTMVar progress (0, "Loading test level...")
testData <- TestData <$> constructMap testLevelDesc 0
atomically $ do
_ <- takeTMVar dataContainer
putTMVar dataContainer testData
_ <- takeTMVar progress
putTMVar progress (1, "Loaded test level!")