Last active
July 13, 2024 02:16
-
-
Save aavogt/191c4d80fae83ce996748aab9c1d2ca6 to your computer and use it in GitHub Desktop.
raylib essence-of-live-coding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE Arrows #-} | |
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE TypeApplications #-} | |
-- ghcid -c 'ghci -isrc' src/Gui.hs -T'sync prog' | |
module Gui (module Gui) where | |
import LiveCoding | |
import Raylib.Util ( WindowResources, drawing ) | |
import Control.Monad.IO.Class ( MonadIO(liftIO) ) | |
import Raylib.Core | |
( clearBackground, | |
closeWindow, | |
initWindow, | |
setTargetFPS, | |
windowShouldClose ) | |
import Raylib.Core.Text ( drawText ) | |
import Raylib.Util.Colors ( black, white ) | |
import Control.Monad | |
import LiveCoding.GHCi (sync) | |
rayguiWrapC :: Int -> Int -> String -> Int -> Cell (HandlingStateT IO) () WindowResources | |
rayguiWrapC w h name fps = handling (Handle openWindow closeWindow) | |
where | |
openWindow = initWindow w h name <* setTargetFPS fps | |
prog :: LiveProgram IO | |
prog = runHandlingState $ liveCell $ proc () -> do | |
wr <- rayguiWrapC 640 480 "hgcode" 10 -< () | |
let render :: IO () | |
render = do | |
drawing do | |
clearBackground black | |
drawText "Hello World" 10 10 20 white | |
done <- windowShouldClose | |
when done (closeWindow wr) | |
ArrM liftIO -< render |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment