packages feed

h-raylib-5.1.1.0: examples/basic-window/src/Main.hs

{-# OPTIONS -Wall #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where

import Raylib.Core (clearBackground, initWindow, setTargetFPS, windowShouldClose, closeWindow)
import Raylib.Core.Text (drawText)
import Raylib.Util (drawing, raylibApplication, WindowResources)
import Raylib.Util.Colors (lightGray, rayWhite)

startup :: IO WindowResources
startup = do
  window <- initWindow 600 450 "raylib [core] example - basic window"
  setTargetFPS 60
  return window

mainLoop :: WindowResources -> IO WindowResources
mainLoop window =
  drawing
    ( do
        clearBackground rayWhite
        drawText "Basic raylib window" 30 40 18 lightGray
    ) >> return window

shouldClose :: WindowResources -> IO Bool
shouldClose _ = windowShouldClose

teardown :: WindowResources -> IO ()
teardown = closeWindow

$(raylibApplication 'startup 'mainLoop 'shouldClose 'teardown)