blob: 9fb874a173c9cf93cb354d866ab7c83d67992a2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
module Beekeep
( Garden
, Block (..)
, gardenWidth
, gardenHeight
, newGarden
, gardenSet
, gardenGet
) where
import Bee
import Plant
import Data.Array.IO
someFunc :: IO ()
someFunc = putStrLn "someFunc"
data Block =
BEmpty
| BPlant Plant
| BHive Beehive
type Garden = IOArray Int Block
gardenWidth :: Int
gardenWidth = 128
gardenHeight :: Int
gardenHeight = 128
newGarden :: IO Garden
newGarden = newArray (1, gardenWidth * gardenHeight) BEmpty
calcGardenIndex :: (Int, Int) -> Int
calcGardenIndex (x, y) = x + y * gardenHeight
gardenGet :: Garden -> (Int, Int) -> IO Block
gardenGet g coords = readArray g (calcGardenIndex coords)
gardenSet :: Garden -> (Int, Int) -> Block -> IO ()
gardenSet g coords b = writeArray g (calcGardenIndex coords) b
|