renderer-tutorial/src/Scenes/SceneClass.hs

24 lines
622 B
Haskell
Raw Normal View History

2020-08-29 02:41:23 +00:00
{-# LANGUAGE ExistentialQuantification #-}
module Scenes.SceneClass where
import qualified SDL
class SceneClass a where
2020-08-29 05:13:49 +00:00
-- | Perform initialization.
initScene :: IO a
2020-08-29 02:41:23 +00:00
-- | Run updates on the data given the time elapsed since last frame
update :: a -> Float -> IO ()
-- | Handle input events
onEvents :: a -> [SDL.Event] -> IO ()
-- | perform the drawing
render :: a -> IO ()
-- Existential type wrapper to make all Scenes implementing SceneClass
-- homogenous.
-- See more at https://wiki.haskell.org/Existential_type#Dynamic_dispatch_mechanism_of_OOP
data Scene = forall a. SceneClass a => Scene a