I posted this code in another thread. It's a basic example of array collision.
`get a white square for the walls and a red one for the player
box 0,0,32,32
get image 1,0,0,32,32,1
ink rgb(255,0,0),0
box 0,0,32,32
get image 5,0,0,32,32,1
ink rgb(255,255,255),0
cls
`image numbers
`
`1 = white wall square
`5 = red player square
sync rate 30
`map size is 20x15 as each tile is 32x32 this fills a 640x480 screen
dim map(19,14)as integer
x as integer : y as integer
xx as integer : yy as integer
`put some data in map the array
`border around play area
y = 0
for x = 0 to 19
map(x,y) = 1
next x
y = 14
for x = 0 to 19
map(x,y) = 1
next x
x = 0
for y = 0 to 14
map(x,y) = 1
next y
x = 19
for y = 0 to 14
map(x,y) = 1
next y
`draw some vertical lines
x = 10
for y = 0 to 5
map(x,y) = 1
next y
x = 17
for y = 10 to 14
map(x,y) = 1
next y
x = 5
for y = 0 to 10
map(x,y) = 1
next y
`and some horzontal lines
y = 5
for x = 15 to 19
map(x,y) = 1
next x
y = 8
for x = 8 to 19
map(x,y) = 1
next x
px as integer : `x pos of player
px = 10
py as integer : `y pos of player
py = 7
pd as integer : `direction of player, 1 = up, 2 = down, 3 = left, 4 = right
pd = 3
do
cls
`draw the map
xx = 0 : yy = 0
for y = 0 to 14
for x = 0 to 19
if map(x,y) = 1 then paste image 1,xx,yy
inc xx,32
next x
xx = 0
inc yy,32
next y
`control the player
if upkey() then pd = 1
if downkey() then pd = 2
if leftkey() then pd = 3
if rightkey() then pd = 4
`move the player
if pd = 1 : `up
if map(px,py-1) = 0 then dec py
endif
if pd = 2 : `down
if map(px,py+1) = 0 then inc py
endif
if pd = 3 : `left
if map(px-1,py) = 0 then dec px
endif
if pd = 4 : `right
if map(px+1,py) = 0 then inc px
endif
`draw the player
paste image 5,px*32,py*32
loop
Make an effort to understand what the code is doing. You won't learn just copy pasteing someone elses code unless you go through it and work out what is going on.
Break it up into pieces and work out what is happening and why.