make make
This commit is contained in:
parent
5661e72cf2
commit
8fc717fd8b
5 changed files with 40 additions and 18 deletions
|
@ -56,6 +56,7 @@ executable haskelloids
|
||||||
other-modules: InGame
|
other-modules: InGame
|
||||||
, Types
|
, Types
|
||||||
, Commons
|
, Commons
|
||||||
|
, Transitions
|
||||||
|
|
||||||
-- LANGUAGE extensions used by modules in this package.
|
-- LANGUAGE extensions used by modules in this package.
|
||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
|
|
|
@ -174,21 +174,6 @@ load _ = do
|
||||||
, state = Menu
|
, state = Menu
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMenu :: UserData -> IO UserData
|
|
||||||
loadMenu ud = do
|
|
||||||
gegl_node_link (nodeGraph ud M.! KeyMenuOver) (nodeGraph ud M.! KeyFGNop)
|
|
||||||
hs <- catMaybes <$> foldM (\acc _ -> do
|
|
||||||
px <- randomRIO (0, 800)
|
|
||||||
py <- randomRIO (0, 600)
|
|
||||||
insertHaskelloid acc Nothing (px, py)
|
|
||||||
) [] ([0..9] :: [Int])
|
|
||||||
liftIO $ gegl_node_link_many $ map hFlange hs
|
|
||||||
liftIO $ gegl_node_link (last $ map hFlange hs) (nodeGraph ud M.! KeyHNop)
|
|
||||||
return ud
|
|
||||||
{ haskelloids = hs
|
|
||||||
, fade = FadeIn 1
|
|
||||||
}
|
|
||||||
|
|
||||||
insertHaskelloid :: [Maybe Haskelloid] -> Maybe Int -> (Double, Double) -> IO [Maybe Haskelloid]
|
insertHaskelloid :: [Maybe Haskelloid] -> Maybe Int -> (Double, Double) -> IO [Maybe Haskelloid]
|
||||||
insertHaskelloid hasks split (px, py) = do
|
insertHaskelloid hasks split (px, py) = do
|
||||||
-- liftIO $ traceIO "inserting haskelloid"
|
-- liftIO $ traceIO "inserting haskelloid"
|
||||||
|
|
|
@ -26,7 +26,7 @@ main = withAffection $ AffectionConfig
|
||||||
{ initComponents = All
|
{ initComponents = All
|
||||||
, windowTitle = "Haskelloids"
|
, windowTitle = "Haskelloids"
|
||||||
, windowConfig = defaultWindow
|
, windowConfig = defaultWindow
|
||||||
, preLoop = return ()
|
, preLoop = transition
|
||||||
, drawLoop = draw
|
, drawLoop = draw
|
||||||
, updateLoop = update
|
, updateLoop = update
|
||||||
, loadState = load
|
, loadState = load
|
||||||
|
@ -86,6 +86,9 @@ update sec = do
|
||||||
, shots = ups
|
, shots = ups
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transition :: Affection us ()
|
||||||
|
transition = return ()
|
||||||
|
|
||||||
wrapAround :: (Ord t, Num t) => (t, t) -> t -> (t, t)
|
wrapAround :: (Ord t, Num t) => (t, t) -> t -> (t, t)
|
||||||
wrapAround (nx, ny) width = (nnx, nny)
|
wrapAround (nx, ny) width = (nnx, nny)
|
||||||
where
|
where
|
||||||
|
|
21
src/Transitions.hs
Normal file
21
src/Transitions.hs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
module Transitions where
|
||||||
|
|
||||||
|
import Affection
|
||||||
|
import qualified SDL
|
||||||
|
import GEGL
|
||||||
|
import BABL
|
||||||
|
|
||||||
|
loadMenu :: UserData -> IO UserData
|
||||||
|
loadMenu ud = do
|
||||||
|
gegl_node_link (nodeGraph ud M.! KeyMenuOver) (nodeGraph ud M.! KeyFGNop)
|
||||||
|
hs <- catMaybes <$> foldM (\acc _ -> do
|
||||||
|
px <- randomRIO (0, 800)
|
||||||
|
py <- randomRIO (0, 600)
|
||||||
|
insertHaskelloid acc Nothing (px, py)
|
||||||
|
) [] ([0..9] :: [Int])
|
||||||
|
liftIO $ gegl_node_link_many $ map hFlange hs
|
||||||
|
liftIO $ gegl_node_link (last $ map hFlange hs) (nodeGraph ud M.! KeyHNop)
|
||||||
|
return ud
|
||||||
|
{ haskelloids = hs
|
||||||
|
, fade = FadeIn 1
|
||||||
|
}
|
16
src/Types.hs
16
src/Types.hs
|
@ -1,3 +1,5 @@
|
||||||
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||||
|
|
||||||
module Types where
|
module Types where
|
||||||
|
|
||||||
import Affection
|
import Affection
|
||||||
|
@ -15,7 +17,7 @@ data UserData = UserData
|
||||||
-- , debris :: ParticleSystem
|
-- , debris :: ParticleSystem
|
||||||
, wonlost :: Bool
|
, wonlost :: Bool
|
||||||
, pixelSize :: Int
|
, pixelSize :: Int
|
||||||
, state :: StateMachine
|
, state :: State
|
||||||
, fade :: MenuFade
|
, fade :: MenuFade
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,11 +60,21 @@ data NodeKey
|
||||||
| KeyMenuOver
|
| KeyMenuOver
|
||||||
deriving (Ord, Eq)
|
deriving (Ord, Eq)
|
||||||
|
|
||||||
data StateMachine
|
data State
|
||||||
= Menu
|
= Menu
|
||||||
| HighScore
|
| HighScore
|
||||||
| InGame
|
| InGame
|
||||||
|
|
||||||
|
class StateMachine a us where
|
||||||
|
load :: a -> Affection us ()
|
||||||
|
update :: a -> Affection us ()
|
||||||
|
draw :: a -> Affection us ()
|
||||||
|
clean :: a -> Affection us ()
|
||||||
|
|
||||||
|
instance StateMachine State UserData where
|
||||||
|
update Menu = return ()
|
||||||
|
|
||||||
|
|
||||||
data MenuFade
|
data MenuFade
|
||||||
= FadeIn Double
|
= FadeIn Double
|
||||||
| FadeOut Double
|
| FadeOut Double
|
||||||
|
|
Loading…
Reference in a new issue