I know why this is done.
Your checking the array from left to right, up to down. So when you reposition it , say 1 tile lower, on the next loop it will find it there, so it will lower it once again, and then again and again.
How to solve it?... well, i'd do it by, instead of repositioning within the for/next loops, do it outside of it, but you could also exit from the for/next loop once you've done the moving operation. Do it by assigning "f" and "t" their proper max values, like this:
cls
sync rate 60
sync on
rem load images
load bitmap "tiles.bmp",1
get image 1,0,0,20,20
get image 2,20,0,40,20
get image 3,40,0,60,20
delete bitmap 1
width#=14
height#=14
dim grid(width#,height#)
grid(5,0)=1
do
cls
for t=0 to width#
for f=0 to height#
if grid(t,f)=1
paste image 3,t*20,f*20
endif
if grid(t,f)=0
paste image 1,t*20,f*20
endif
next f
next t
if downkey()=1
for t=0 to width#
for f=0 to height#
if grid(t,f)=1
if f<height#
grid(t,f)=0
n=f+1
grid(t,n)=1
t=width#
f=height#
endif
endif
next f
next t
endif
if upkey()=1
for t=0 to width#
for f=0 to height#
if grid(t,f)=1
if f>0
grid(t,f)=0
n=f-1
grid(t,n)=1
t=width#
f=height#
endif
endif
next f
next t
endif
if leftkey()=1
for t=0 to width#
for f=0 to height#
if grid(t,f)=1
if t>0
grid(t,f)=0
n=t-1
grid(n,f)=1
t=width#
f=height#
endif
endif
next f
next t
endif
if rightkey()=1
for t=0 to width#
for f=0 to height#
if grid(t,f)=1
if t<width#
grid(t,f)=0
n=t+1
grid(n,f)=1
t=width#
f=height#
endif
endif
next f
next t
endif
sync
loop
I know that up and right works ok, but it is best to exit the loop, and not make the cpu work needless operations.
Further on my stuff at...