The easiest way to do a 2D map is with a 2D array that usually stores either the image number or sprite number of each tile.
` Dimensionalize the 2D array
dim Map(99,99)
` Create 10 images (tiles)
for t=1 to 10
` Pick a random color
ink rgb(rnd(255),rnd(255),rnd(255)),0
` Make a box
box 0,0,32,32
` Change color to bright white
ink rgb(255,255,255),0
` Show tile number
center text 15,10,str$(t)
` Grab the tile
get image t,0,0,32,32,1
next t
` Go though each map location
for x=0 to 99
for y=0 to 99
` Make the current map location be a random tile number
Map(x,y)=rnd(9)+1
next x
next y
` Show the tiles in the map
for y=0 to screen height() step 32
for x=0 to screen width() step 32
` Place the tile
paste image Map(MapX,MapY),x,y,1
` Go to next MapX
inc MapX
next x
` Go to next MapY
inc MapY
` Reset MapX
MapX=0
next y
wait key