about summary refs log tree commit diff stats
path: root/Main.hs
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2013-04-02 01:57:09 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2013-04-02 01:57:09 -0400
commit94fc90c32fb9d6694a95a9c191553aa39eabd10a (patch)
treeefafaeee96cba98f76353e18f59f0cb045fc6d70 /Main.hs
parent8cb868224840c734f38e9041aa1567cdecd17797 (diff)
downloadfallen-hs-94fc90c32fb9d6694a95a9c191553aa39eabd10a.tar.gz
fallen-hs-94fc90c32fb9d6694a95a9c191553aa39eabd10a.tar.bz2
fallen-hs-94fc90c32fb9d6694a95a9c191553aa39eabd10a.zip
Got rid of pure functional randomness and started using IO monad
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs21
1 files changed, 10 insertions, 11 deletions
diff --git a/Main.hs b/Main.hs index 4908c59..4b859fb 100644 --- a/Main.hs +++ b/Main.hs
@@ -8,32 +8,31 @@ module Main where
8 8
9 -- main :: () 9 -- main :: ()
10 main = do 10 main = do
11 rg <- getStdGen 11 m <- initOverworld
12 let (m,rg') = initOverworld rg
13 initCurses 12 initCurses
14 keypad stdScr True 13 keypad stdScr True
15 echo False 14 echo False
16 cursSet CursorInvisible 15 cursSet CursorInvisible
17 startColor 16 startColor
18 mainLoop (75,75) m rg' 17 mainLoop (75,75) m
19 endWin 18 endWin
20 19
21 mainLoop player m rg = do 20 mainLoop player m = do
22 render player m 21 render player m
23 input <- getCh 22 input <- getCh
24 case input of 23 case input of
25 KeyLeft -> moveIfPassable player m rg West 24 KeyLeft -> moveIfPassable player m West
26 KeyRight -> moveIfPassable player m rg East 25 KeyRight -> moveIfPassable player m East
27 KeyUp -> moveIfPassable player m rg North 26 KeyUp -> moveIfPassable player m North
28 KeyDown -> moveIfPassable player m rg South 27 KeyDown -> moveIfPassable player m South
29 _ -> putStrLn "endgame" 28 _ -> putStrLn "endgame"
30 29
31 moveIfPassable player m rg dir = do 30 moveIfPassable player m dir = do
32 let p' = stepInDirection player dir 31 let p' = stepInDirection player dir
33 let t' = getTileAtPos m p' 32 let t' = getTileAtPos m p'
34 if t' `elem` passableTiles 33 if t' `elem` passableTiles
35 then mainLoop p' m rg 34 then mainLoop p' m
36 else mainLoop player m rg 35 else mainLoop player m
37 36
38 -- render :: Point -> Map -> Window -> () 37 -- render :: Point -> Map -> Window -> ()
39 render (px,py) m = do 38 render (px,py) m = do