diff options
Diffstat (limited to 'Demos/Pong/Main.hs')
-rw-r--r-- | Demos/Pong/Main.hs | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/Demos/Pong/Main.hs b/Demos/Pong/Main.hs index 993c0ff..22b1021 100644 --- a/Demos/Pong/Main.hs +++ b/Demos/Pong/Main.hs | |||
@@ -7,7 +7,7 @@ import Pong | |||
7 | import Spear.App | 7 | import Spear.App |
8 | import Spear.Game | 8 | import Spear.Game |
9 | import Spear.Math.AABB | 9 | import Spear.Math.AABB |
10 | import Spear.Math.Matrix4 as Matrix4 hiding (position) | 10 | import Spear.Math.Matrix4 as Matrix4 |
11 | import Spear.Math.Spatial | 11 | import Spear.Math.Spatial |
12 | import Spear.Math.Spatial2 | 12 | import Spear.Math.Spatial2 |
13 | import Spear.Math.Vector | 13 | import Spear.Math.Vector |
@@ -20,12 +20,10 @@ import Spear.Sound.State | |||
20 | import Spear.Window | 20 | import Spear.Window |
21 | 21 | ||
22 | import Control.Monad (when) | 22 | import Control.Monad (when) |
23 | import Data.Maybe (mapMaybe) | ||
24 | 23 | ||
25 | 24 | ||
26 | data Pong = Pong | 25 | data Pong = Pong |
27 | { immRenderState :: ImmRenderState | 26 | { viewProjection :: Matrix4 |
28 | , viewProjection :: Matrix4 | ||
29 | , backgroundMusic :: SoundSource | 27 | , backgroundMusic :: SoundSource |
30 | , world :: [GameObject] | 28 | , world :: [GameObject] |
31 | } | 29 | } |
@@ -43,10 +41,6 @@ main = runApp app | |||
43 | 41 | ||
44 | initGame :: Game AppContext Pong | 42 | initGame :: Game AppContext Pong |
45 | initGame = do | 43 | initGame = do |
46 | renderCoreState <- contextRenderCoreState <$> get | ||
47 | (immRenderState, renderCoreState') <- runSiblingGame renderCoreState newImmRenderer | ||
48 | -- TODO: This can work if we use FlexibleContexts and change the function signatures. | ||
49 | --immRenderState <- newImmRenderer | ||
50 | music <- siblingGame $ do | 44 | music <- siblingGame $ do |
51 | musicBuffer <- loadAudioFile "/home/jeanne/Casual Tiki Party Main.wav" | 45 | musicBuffer <- loadAudioFile "/home/jeanne/Casual Tiki Party Main.wav" |
52 | music <- makeSoundSource | 46 | music <- makeSoundSource |
@@ -54,13 +48,10 @@ initGame = do | |||
54 | setSoundLoopMode music Loop | 48 | setSoundLoopMode music Loop |
55 | playSounds [music] | 49 | playSounds [music] |
56 | return music | 50 | return music |
57 | return $ Pong immRenderState Matrix4.id music newWorld | 51 | return $ Pong Matrix4.id music newWorld |
58 | 52 | ||
59 | endGame :: Game GameState () | 53 | endGame :: Game GameState () |
60 | endGame = do | 54 | endGame = return () |
61 | renderCoreState <- appRenderCoreState <$> get | ||
62 | game <- getGameState | ||
63 | exec' runSiblingGame renderCoreState (deleteImmRenderer $ immRenderState game) | ||
64 | 55 | ||
65 | 56 | ||
66 | step :: Elapsed -> Dt -> [InputEvent] -> Game GameState Bool | 57 | step :: Elapsed -> Dt -> [InputEvent] -> Game GameState Bool |
@@ -86,7 +77,7 @@ exitRequested = elem (KeyDown KEY_ESC) | |||
86 | render :: Game GameState () | 77 | render :: Game GameState () |
87 | render = do | 78 | render = do |
88 | gameState <- getGameState | 79 | gameState <- getGameState |
89 | immRenderState' <- exec runSiblingGame (immRenderState gameState) $ do | 80 | siblingGame $ do |
90 | immStart | 81 | immStart |
91 | immSetViewProjectionMatrix (viewProjection gameState) | 82 | immSetViewProjectionMatrix (viewProjection gameState) |
92 | -- Clear the background to a different colour than the playable area to make | 83 | -- Clear the background to a different colour than the playable area to make |
@@ -95,7 +86,6 @@ render = do | |||
95 | clearBuffers [ColourBuffer] | 86 | clearBuffers [ColourBuffer] |
96 | render' $ world gameState | 87 | render' $ world gameState |
97 | immEnd | 88 | immEnd |
98 | putGameState $ gameState { immRenderState = immRenderState' } | ||
99 | 89 | ||
100 | render' :: [GameObject] -> Game ImmRenderState () | 90 | render' :: [GameObject] -> Game ImmRenderState () |
101 | render' world = do | 91 | render' world = do |