summary refs log tree commit diff
path: root/src/Beekeep.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Beekeep.hs')
-rw-r--r--src/Beekeep.hs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/Beekeep.hs b/src/Beekeep.hs
new file mode 100644
index 0000000..9fb874a
--- /dev/null
+++ b/src/Beekeep.hs
@@ -0,0 +1,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
+