renderer-tutorial/src/Scenes/SceneClass.hs
2020-08-29 04:45:51 +02:00

21 lines
570 B
Haskell

{-# LANGUAGE ExistentialQuantification #-}
module Scenes.SceneClass where
import qualified SDL
class SceneClass a where
-- | 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