From 94fc90c32fb9d6694a95a9c191553aa39eabd10a Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 2 Apr 2013 01:57:09 -0400 Subject: Got rid of pure functional randomness and started using IO monad --- Main.hs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'Main.hs') 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 -- main :: () main = do - rg <- getStdGen - let (m,rg') = initOverworld rg + m <- initOverworld initCurses keypad stdScr True echo False cursSet CursorInvisible startColor - mainLoop (75,75) m rg' + mainLoop (75,75) m endWin - mainLoop player m rg = do + mainLoop player m = do render player m input <- getCh case input of - KeyLeft -> moveIfPassable player m rg West - KeyRight -> moveIfPassable player m rg East - KeyUp -> moveIfPassable player m rg North - KeyDown -> moveIfPassable player m rg South + KeyLeft -> moveIfPassable player m West + KeyRight -> moveIfPassable player m East + KeyUp -> moveIfPassable player m North + KeyDown -> moveIfPassable player m South _ -> putStrLn "endgame" - moveIfPassable player m rg dir = do + moveIfPassable player m dir = do let p' = stepInDirection player dir let t' = getTileAtPos m p' if t' `elem` passableTiles - then mainLoop p' m rg - else mainLoop player m rg + then mainLoop p' m + else mainLoop player m -- render :: Point -> Map -> Window -> () render (px,py) m = do -- cgit 1.4.1