Permalink
Browse files

Updating the step count

  • Loading branch information...
1 parent f8bc32c commit 00be886bed60e9177da998f9738ab25210e40d3d @roman roman committed Aug 26, 2010
Showing with 4 additions and 10 deletions.
  1. +2 −8 HaskBan.hs
  2. +2 −2 input.in
View
@@ -23,8 +23,6 @@ module HaskBan (main) where
main :: SokobanMonad ()
main = do
window <- liftIO setupHaskBanGUI
- liftIO $ showMoves window 0
- liftIO refresh
loopUntil (readKeyAndPrint window)
liftIO $ endWin
@@ -42,17 +40,11 @@ module HaskBan (main) where
liftIO endWin
return True
else do
- incrNumberOfSteps
- steps <- getNumberOfSteps
- liftIO $ showMoves window steps
isFinished <- keyPressed key
when isFinished (liftIO (wclear window >> printYouWonScreen window))
liftIO $ refresh
return isFinished
- showMoves :: Window -> Int -> IO ()
- showMoves w s = mvWAddStr w 3 30 ("Number of key-presses: " ++ show s)
-
-- keyPressed :: (MonadState SokobanInfo) m => Key -> m ()
keyPressed :: Key -> SokobanMonad Bool
keyPressed k = do
@@ -74,7 +66,9 @@ module HaskBan (main) where
displaySokobanMap :: Window -> SokobanMonad ()
displaySokobanMap window = do
sokobanMap <- getMap
+ steps <- getNumberOfSteps
liftIO $ do
let sokoMapStr = showSokoMap sokobanMap
mvWAddStr window 2 0 sokoMapStr
+ mvWAddStr window 3 30 ("Number of key-presses: " ++ show steps)
refresh
View
@@ -2,12 +2,12 @@ Level 1
#########
## ####
## #
-### **# #
+## **# #
# #* *@#
# * ###
# ## ##
## ##
-##.$# ##
+##.$ ##
## #####
#########

0 comments on commit 00be886

Please sign in to comment.