LoginSignup
10
10

More than 5 years have passed since last update.

Haskell/Graphics.Gloss

Last updated at Posted at 2012-09-15

"世界で一番柔軟かつ簡単にグラフィックや入出力ができるライブラリ"であるGraphics.Glossを使うにあたっての雛形(テンプレート)

Main.hs
module Main where

import Graphics.Gloss.Interface.Pure.Game

data World = World { picture :: Picture }

main :: IO ()
main
  = play (InWindow "Templete" (800, 600) (10, 10))
    black
    60
    initWorld
    draw
    handleInput
    (\_ s -> s )

initWorld :: World
initWorld = World { picture = Blank }

draw :: World -> Picture
draw (World _) = Blank

handleInput :: Event -> World -> World
handleInput (EventKey k ks _ _) s = s
handleInput (EventMotion _) s = s

なお、キー操作などを必要としないプログラムであればもう少し簡単に書くことが可能。

10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10