Quote: "
function loadmap(filename$,size)
open to read 1,filename$
for y=1 to size
for x=1 to size
read byte 1,tmp
map$(x,y)=chr$(tmp)
next x
next y
close file 1
endfunction
"
baps, your For Loop code is reading the map file wrong in the source code you provided!
Going by what you've supplied, I've made the necessary changes here:
Rem NOTE: This source is unuseable on it's own in it's current state and is not a fully working example!
Rem Imagine what a map looks like:
`0123456
`<--X-->
`A000000 ^ 0
`0000000 | 1
`0000B00 Y 2
`0000000 | 3
`0000000 V 4
`
` A is at Grid Ref 0X,0Y - That's why starting at 0 in For Loops becomes important
` B is at Grid Ref 4X,2Y
XMAX=7 : Rem (0 to 6 = 7 in Row)
YMAX=5 : Rem (0 to 4 = 5 in Column)
SIZE=XMAX*YMAX : Rem The FILESIZE will be (number of columns multiplied by number of rows)
LoadMap("C:YourPath",XMAX,YMAX)
Function LoadMap(FILENAME$,XM,YM)
Rem Notice your SIZE variable is not being used in this function
Rem because it actually holds the TOTAL value of ALL the spaces in rows and columns (X and Y) together
Rem Starting at 0 is a good habit to get into
Open to Read 1,FILENAME$
For Y=0 to YM-1 : Rem Read map top to bottom (0 to 4)
For X=0 to XM-1 : Rem Read map left to right (0 to 6)
Read Byte 1,TMP
MAP$(X,Y)=Chr$(TMP)
Next X
Next Y
Close File 1
EndFunction