changes in the engine
This commit is contained in:
parent
ef6aa71142
commit
5841774284
3 changed files with 27 additions and 13 deletions
|
@ -66,7 +66,7 @@ executable haskelloids
|
||||||
, affection
|
, affection
|
||||||
, gegl
|
, gegl
|
||||||
, babl
|
, babl
|
||||||
, sdl2
|
, sdl2 >= 2.1.3.1
|
||||||
, containers
|
, containers
|
||||||
, random
|
, random
|
||||||
|
|
||||||
|
|
|
@ -18,18 +18,22 @@ import Commons
|
||||||
|
|
||||||
loadGame :: Affection UserData ()
|
loadGame :: Affection UserData ()
|
||||||
loadGame = do
|
loadGame = do
|
||||||
|
liftIO $ traceIO "loading game"
|
||||||
ud <- getAffection
|
ud <- getAffection
|
||||||
_ <- liftIO $ gegl_node_connect_to
|
_ <- liftIO $ gegl_node_connect_to
|
||||||
(nodeGraph ud M.! KeyShipTranslate)
|
(nodeGraph ud M.! KeyShipTranslate)
|
||||||
"output"
|
"output"
|
||||||
(nodeGraph ud M.! KeyShipOver)
|
(nodeGraph ud M.! KeyShipOver)
|
||||||
"aux"
|
"aux"
|
||||||
|
liftIO $ traceIO "nodes connected"
|
||||||
hs <- liftIO $ catMaybes <$> foldM (\acc _ -> do
|
hs <- liftIO $ catMaybes <$> foldM (\acc _ -> do
|
||||||
coords <- liftIO excludeShip
|
coords <- liftIO excludeShip
|
||||||
insertHaskelloid acc Nothing coords
|
insertHaskelloid acc Nothing coords
|
||||||
) [] ([0..9] :: [Int])
|
) [] ([0..9] :: [Int])
|
||||||
|
liftIO $ traceIO "inserted haskelloids"
|
||||||
liftIO $ gegl_node_link_many $ map hFlange hs
|
liftIO $ gegl_node_link_many $ map hFlange hs
|
||||||
liftIO $ gegl_node_link (last $ map hFlange hs) (nodeGraph ud M.! KeyHNop)
|
liftIO $ gegl_node_link (last $ map hFlange hs) (nodeGraph ud M.! KeyHNop)
|
||||||
|
liftIO $ traceIO "nodes linked"
|
||||||
putAffection ud
|
putAffection ud
|
||||||
{ haskelloids = hs
|
{ haskelloids = hs
|
||||||
, wonlost = False
|
, wonlost = False
|
||||||
|
@ -46,6 +50,11 @@ loadGame = do
|
||||||
, pixelSize = 3
|
, pixelSize = 3
|
||||||
, state = InGame
|
, state = InGame
|
||||||
}
|
}
|
||||||
|
liftIO $ traceIO "game loaded"
|
||||||
|
present
|
||||||
|
(GeglRectangle 0 0 800 600)
|
||||||
|
(buffer ud)
|
||||||
|
True
|
||||||
|
|
||||||
excludeShip :: IO (Double, Double)
|
excludeShip :: IO (Double, Double)
|
||||||
excludeShip = do
|
excludeShip = do
|
||||||
|
@ -104,19 +113,25 @@ updateGame sec = do
|
||||||
|
|
||||||
drawGame :: Affection UserData ()
|
drawGame :: Affection UserData ()
|
||||||
drawGame = do
|
drawGame = do
|
||||||
|
-- ud <- getAffection
|
||||||
|
-- liftIO $ gegl_node_process $ nodeGraph ud M.! KeySink
|
||||||
|
-- present
|
||||||
|
-- (GeglRectangle (floor $ fst $ sPos $ ship ud) (floor $ snd $ sPos $ ship ud) 50 50)
|
||||||
|
-- (buffer ud)
|
||||||
|
-- False
|
||||||
|
-- mapM_ (\h -> do
|
||||||
|
-- let s = 100 `div` hDiv h
|
||||||
|
-- present
|
||||||
|
-- (GeglRectangle (floor $ fst $ hPos h) (floor $ snd $ hPos h) s s)
|
||||||
|
-- (buffer ud)
|
||||||
|
-- False
|
||||||
|
-- ) (haskelloids ud)
|
||||||
ud <- getAffection
|
ud <- getAffection
|
||||||
liftIO $ gegl_node_process $ nodeGraph ud M.! KeySink
|
liftIO $ gegl_node_process $ nodeGraph ud M.! KeySink
|
||||||
present
|
present
|
||||||
(GeglRectangle (floor $ fst $ sPos $ ship ud) (floor $ snd $ sPos $ ship ud) 50 50)
|
(GeglRectangle 0 0 800 600)
|
||||||
(buffer ud)
|
(buffer ud)
|
||||||
False
|
True
|
||||||
mapM_ (\h -> do
|
|
||||||
let s = 100 `div` hDiv h
|
|
||||||
present
|
|
||||||
(GeglRectangle (floor $ fst $ hPos h) (floor $ snd $ hPos h) s s)
|
|
||||||
(buffer ud)
|
|
||||||
False
|
|
||||||
) (haskelloids ud)
|
|
||||||
|
|
||||||
handleGameEvent :: Double -> SDL.Event -> Affection UserData ()
|
handleGameEvent :: Double -> SDL.Event -> Affection UserData ()
|
||||||
handleGameEvent sec e = do
|
handleGameEvent sec e = do
|
||||||
|
|
|
@ -44,11 +44,10 @@ pre = do
|
||||||
-- (buffer ud)
|
-- (buffer ud)
|
||||||
-- True
|
-- True
|
||||||
|
|
||||||
update :: Double -> Affection UserData ()
|
update :: Double -> [SDL.Event] -> Affection UserData ()
|
||||||
update sec = do
|
update sec evs = do
|
||||||
wd <- getAffection
|
wd <- getAffection
|
||||||
smUpdate (state wd) sec
|
smUpdate (state wd) sec
|
||||||
evs <- SDL.pollEvents
|
|
||||||
mapM_ (smEvent (state wd) sec) evs
|
mapM_ (smEvent (state wd) sec) evs
|
||||||
|
|
||||||
draw :: Affection UserData ()
|
draw :: Affection UserData ()
|
||||||
|
|
Loading…
Add table
Reference in a new issue