how to store new values in variables?
Anders Elfgren
srekel@dtek.chalmers.se
Wed, 31 Oct 2001 15:59:52 +0100 (MET)
Hi, its me with the dungeon master-game again.. I'm in the process of
making me able to move around, which I have succeeded with. Kind of.
Remember the map
type Pic = [[Char]]
maplevel1 = ["##############",
"# #",
"### #",
"# #",
"# # #",
"#P# #",
"# #m #",
"##############"]
Now, I've made a function called s (for south) which just moves the 'P'
one step down. It looks like this
s :: Pic
s = remap (findPos 'P' 1) (0,1) 1
findPos just finds the positin of the P, and 0,1 tells remap to move it
one step on the y-axis. The remap function looks overly complicated right
now so I'm not gonna put it in here, nad I dont think it really matters.
What I want to do tho, is something like this
s :: Pic
s = maplevel1 <- (remap (findPos 'P' 1) (0,1) 1)
so that it not only returns the new Pic, but also sets the maplevel1
variable to look like it should after the move.
If I do
putStr (unlines s)
twice, it should move down two steps.. but it doesnt.
We didn't learn this, well I didn't :), in the Haskell course so if
someone can just give me an example of how I should do it it'd be nice..
Thanks again.
The dm2.hs can be downloaded from
www.dtek.chalmers.se/~srekel/ptf
and yes, the draw2 function works :)
-------------------------------------------------------------------------
Anders Elfgren || AKA: Srekel and Farfar
Homepage: http://hem.passagen.se/srekel || Alt email: srekel@icqmail.com
ICQ: 4596105 || AIM: Srekel
- Kaka e gott || - Cs e halva mitt liv
-------------------------------------------------------------------------