rem scroll screen challenge
rem 11/10/2009
rem by Latch
 
set display mode 800,600,16
sync on
sync rate 0
 
rem array
dim tiles(38)
 
rem create images
for n=1 to 16
   c=255/n
   cls rgb(c,c,c)
   get image n,0,0,16,16
   sync
next n
cls 0
 
rem shuffle images in array
for n=1 to 38
   tiles(n)=rnd(15)+1
next n
 
rem create a background bitmap to draw tiles on
create bitmap 1,17,600
for y=0 to 37
   paste image tiles(y+1),0,y*16
next y
 
rem screen to print fps
create bitmap 2,60,20
 
rem a few variables
ct=-1
sch=screen height()
scw=screen width()
 
rem scroll screen
do
   rem check the count to see if we've moved across the x of all the tiles
   inc ct
   if ct > 15
      rem rescramble the random tiles
      set current bitmap 1
      for n=1 to 38
         tiles(n)=rnd(15)+1
         paste image tiles(n),0,(n-1)*16
      next n
      ct=0
      rem return to fps display
      set current bitmap 2
   endif
 
   rem first copy the image of the tiles to the edge of bitmap 0
   copy bitmap 1,ct,0,ct+1,sch-1,0,scw-2,0,scw-1,sch-1
   rem then shift bitmap 0 over by 1 pixel
   copy bitmap 0,1,0,scw-1,sch-1,0,0,0,scw-2,sch-1
 
   rem display the fps
   cls
   text 0,0,"FPS: "+str$(screen fps())
   copy bitmap 2,0
 
   sync
loop