You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 17, 2020. It is now read-only.
Currently to change the window size after the engine initialization develop needs to work directly with SDLEngine as shown in the following code. It is bad, as we want to ensure that engine replacement is non-breaking change.
module Main where
import Helm
import Helm.Engine.SDL.Engine
import Helm.Graphics2D
import qualified Helm.Cmd as Cmd
import qualified Helm.Window as Window
import qualified Helm.Engine.SDL as SDL
import Data.StateVar (($=))
import Linear.V2 (V2(V2))
import qualified SDL.Video as Video
data Action = Idle | FitWindow Video.Window (V2 Int)
data Model = Model
initial :: (Model, Cmd SDLEngine Action)
initial = (Model, Cmd.none)
fit :: (V2 Int) -> (V2 Int)
fit (V2 width height) = V2 dimension dimension
where dimension = min width height
update :: Model -> Action -> (Model, Cmd SDLEngine Action)
update model Idle = (model, Cmd.none)
update model (FitWindow window size) = (model, resizeCommand)
where resizeCommand = Cmd.execute (Video.windowSize window $= fromIntegral <$> fit size) $ const Idle
subscriptions :: Video.Window -> Sub SDLEngine Action
subscriptions window = Window.resizes $ FitWindow window
view :: Model -> Graphics SDLEngine
view _ = Graphics2D $ collage []
main :: IO ()
main = do
engine@SDLEngine { window } <- SDL.startup
run engine GameConfig
{ initialFn = initial
, updateFn = update
, subscriptionsFn = subscriptions window
, viewFn = view
}
Engine should have its own setter for window size.
Currently to change the window size after the engine initialization develop needs to work directly with
SDLEngineas shown in the following code. It is bad, as we want to ensure that engine replacement is non-breaking change.Engine should have its own setter for window size.