-- | Main function
main :: IO ()
main = do
wall <- loadBMP "wall.bmp" -- loads wall image
play initialState drawState reactEvent reactTime
-- | Function that creates the game
play :: State -> (State -> Picture) -> (Event -> State -> State) -> (Float -> State -> State) -> IO ()
play initialState drawState reactEvent reactTime = play
(InWindow "Game" (900, 900) (0, 0)) -- Window ize
(greyN 0.5) -- background coloer
1 -- refresh rate
initialState -- initial state
drawState -- draws game state
reactEvent -- teacts to evente
reactTime -- reacts to time
-- | One game represenction
type State = (Map,Picture)
-- | Initial game state
initialState :: State
initialState = ((map 13 0),wall)
The function map creates my map. My game is already running fine, but I need to replace the representations i used (circles from gloss) with some BMP images, but i can't load even one cause when i try to load this wall it appears an error in the last line I shared here: not in scope 'wall'
Can someone see why this is happening?
When you define
main, the variables you create there aren't accessible outside of the definition ofmain.initialStateis outside the definition ofmain.You need to pass
wallintoinitialStateby changingmainandinitialStatelike this: