From 7d12975d0c9b8db4856dd333769216c1b12f75e4 Mon Sep 17 00:00:00 2001 From: nek0 Date: Sat, 4 Nov 2017 16:31:13 +0100 Subject: [PATCH 1/2] pushing bounds --- haskelloids.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haskelloids.cabal b/haskelloids.cabal index 9f4a275..504b840 100644 --- a/haskelloids.cabal +++ b/haskelloids.cabal @@ -61,7 +61,7 @@ executable haskelloids -- other-extensions: -- Other library packages from which modules are imported. - build-depends: base >=4.9 && <4.10 + build-depends: base >=4.9 && <4.11 , affection , gegl , babl From 02242301e2dc023f4d02f3ab0edcaffe9215c8c1 Mon Sep 17 00:00:00 2001 From: nek0 Date: Sat, 4 Nov 2017 18:28:33 +0100 Subject: [PATCH 2/2] doesn't work either --- src/Commons.hs | 4 ++-- src/InGame.hs | 13 +++++++------ src/Main.hs | 19 +++++++++++-------- src/Types.hs | 4 ++-- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/Commons.hs b/src/Commons.hs index 95486f0..286c0b7 100644 --- a/src/Commons.hs +++ b/src/Commons.hs @@ -24,8 +24,8 @@ clean ud = do mapM_ gegl_node_drop $ map (\h -> hNodeGraph h M.! "root") (haskelloids ud) gegl_node_drop $ nodeGraph ud M.! KeyRoot -load :: SDL.Surface -> IO UserData -load _ = do +load :: IO UserData +load = do traceM "loading" root <- gegl_node_new traceM "root node" diff --git a/src/InGame.hs b/src/InGame.hs index e0e86a0..5dae5ad 100644 --- a/src/InGame.hs +++ b/src/InGame.hs @@ -13,11 +13,12 @@ import Debug.Trace import Types import Commons -handleGameEvent :: Double -> SDL.Event -> Affection UserData () -handleGameEvent sec e = do +handleGameEvent :: SDL.EventPayload -> Affection UserData () +handleGameEvent e = do ad <- get wd <- getAffection - case SDL.eventPayload e of + sec <- getDelta + case e of SDL.KeyboardEvent dat -> case (SDL.keysymKeycode $ SDL.keyboardEventKeysym dat) of SDL.KeycodeLeft -> do @@ -72,14 +73,14 @@ handleGameEvent sec e = do { particleTimeToLive = 5 , particleCreation = elapsedTime ad , particlePosition = (posX, posY) - , particleRotation = Rad 0 + , particleRotation = 0 , particleVelocity = -- ( (floor $ -200 * (sin $ toR $ (sRot $ ship ud) + (fst $ sVel $ ship ud))) -- , (floor $ -200 * (cos $ toR $ (sRot $ ship ud) + (snd $ sVel $ ship ud))) ( (floor $ -200 * (sin $ toR $ sRot $ ship ud)) , (floor $ -200 * (cos $ toR $ sRot $ ship ud)) ) - , particlePitchRate = Rad 0 + , particlePitchRate = 0 , particleRootNode = tempRoot , particleNodeGraph = M.fromList [ ("root", tempRoot) @@ -97,7 +98,7 @@ handleGameEvent sec e = do when (SDL.keyboardEventKeyMotion dat == SDL.Pressed) $ do liftIO $ traceIO "reloading" liftIO $ clean wd - nd <- liftIO $ load $ drawSurface ad + nd <- liftIO $ load putAffection nd _ -> return () SDL.WindowClosedEvent _ -> do diff --git a/src/Main.hs b/src/Main.hs index 1a72bce..4ad41c6 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -29,6 +29,9 @@ main = withAffection $ AffectionConfig , updateLoop = update , loadState = load , cleanUp = clean + , canvasSize = Nothing + , initScreenMode = SDL.Windowed + , eventLoop = handleGameEvent } update :: Double -> Affection UserData () @@ -45,13 +48,13 @@ update sec = do putAffection pd { pixelSize = pixelSize wd -1 } - evs <- SDL.pollEvents - mapM_ (\e -> - case state wd of - InGame -> - handleGameEvent sec e - _ -> error "not yet implemented" - ) evs + -- evs <- SDL.pollEvents + -- mapM_ (\e -> + -- case state wd of + -- InGame -> + -- handleGameEvent e + -- _ -> error "not yet implemented" + -- ) evs ud2 <- getAffection nhs <- mapM (updateHaskelloid sec) (haskelloids ud2) -- liftIO $ traceIO $ show $ length nhs @@ -69,7 +72,7 @@ update sec = do liftIO $ gegl_node_set (nodeGraph ud3 M.! KeyRotate) $ Operation "gegl:rotate" [ Property "degrees" $ PropertyDouble $ sRot $ ship ud3 ] - ups <- updateParticleSystem (shots ud3) sec shotsUpd shotsDraw + ups <- updateParticleSystem (shots ud3) sec shotsUpd ud4 <- getAffection putAffection ud4 { ship = (ship ud3) diff --git a/src/Types.hs b/src/Types.hs index 88cd3a2..b7b37b9 100644 --- a/src/Types.hs +++ b/src/Types.hs @@ -15,7 +15,7 @@ data UserData = UserData -- , debris :: ParticleSystem , wonlost :: Bool , pixelSize :: Int - , state :: StateMachine + , state :: State } data Ship = Ship @@ -52,7 +52,7 @@ data NodeKey | KeyFGNop deriving (Ord, Eq) -data StateMachine +data State = Menu | HighScore | InGame