coordToPicture
takes a “Snake coordinate” and makes a
squarePicture
for it. We need to do some conversion here
because the coordinate system of Gloss and the coordinates
for the Snake game are not the same.
In the Gloss coordinate system (0,0)
is the center of the screen.
In the Snake coordinate system (0,0)
represent the upper left square.
Translating the coordinate (0,0)
should result in moving to position (-315,315)
and then drawing a square. Below you see an example of the function in action, note that Polygon here is created by squarePicture
.
*Main> coordToPicture (0,0)
Translate (-315.0) 315.0 (Polygon [(-4.0,-4.0),(-4.0,4.0),(4.0,4.0),(4.0,-4.0)])
Read more about the gloss library here: http://hackage.haskell.org/package/gloss
HINTS:
translate
,fromIntegral
and squarePicture
snake_scale
, width
and height