Time with a small group: 3h including setting up Haskell etc.
We went through some preparatory steps:
- Explain the basics of using a command shell:
pwd
,ls
,cd
,mkdir
,touch
- Launch
ghci
, do some simple arithmetic, lists, and some basic list operations. - Introduce the idea of variables with some simple
let
expression. - Introduce the idea of functions by defining simple functions in a
let
expression and using them.
Then, create a file Game.hs
and put the code for "Hello World!" into it:
main = putStrLn "Hello World!"
Compile it:
ghc -o Game Game.hs
Run it:
./Game
Then, the main part was to develop the version of Game.hs
in this directory. This went as follows:
- Everybody created a sprite for their character with BigPixel.
- Then, they got shown the boilerplate to import
Graphics.Gloss.Game
and invoke theplay
function, doing nothing but callingdraw
(with the world value just being()
). The functiondraw
in turn just shows the sprite. - Talk about modifying Gloss pictures with
scale
andtranslate
(maybe mentionrotate
as well). - Introduce the
World
datatype, initialise it inplay
, and use the character location indraw
. Talk about how changing the initial value changes the drawn picture. - Add the event handler code to move the character.