Here's a small scrolling example I came up with.
Rem Side Scrolling Demo Using Tiles & Arrays
Rem (c) TDK_Man Feb 2007
Gosub Setup
Gosub Create_Tiles
Gosub Build_Screen
Do
If LeftKey() Then Gosub Scroll_Left
If RightKey() Then Gosub Scroll_Right
Sync
Loop
End
Scroll_Left:
If XTileOffset > 0
Set Current Bitmap 1
Dec XPixelOffset,ScrollSpeed
If XPixelOffset <= 0
XPixelOffset=32
Dec XTileOffset
CLS
For Nx=0 To 25
For Ny=0 To 17
Paste Image Tiles(NX+XTileOffset,NY),Nx*32,Ny*32
Next Nx
Next Ny
Endif
Get Image 1000,XPixelOffset,0,806+XPixelOffset,576
Set Current Bitmap 0
Paste Image 1000,0,0
Endif
Return
Scroll_Right:
If XTileOffset < ScrnTileWidth
Set Current Bitmap 1
Inc XPixelOffset,ScrollSpeed
If XPixelOffset >= 32
XPixelOffset=0
Inc XTileOffset
CLS
For Nx=0 To 25
For Ny=0 To 17
Paste Image Tiles(NX+XTileOffset,NY),Nx*32,Ny*32
Next Nx
Next Ny
Endif
Get Image 1000,XPixelOffset,0,806+XPixelOffset,576
Set Current Bitmap 0
Paste Image 1000,0,0
Endif
Return
Build_Screen:
Create Bitmap 1,1024,768
For Nx=0 To 25
For Ny=0 To 17
Paste Image Tiles(NX+XTileOffset,NY),Nx*32,Ny*32
Next Nx
Next Ny
Get Image 1000,XPixelOffset,0,806+XPixelOffset,576
Set Current Bitmap 0
Paste Image 1000,0,0
Ink RGB(255,255,255),0
Set Text Font "Tahoma"
Set Text Size 16
Center Text 400,580,"Use Cursor Left/Right To Scroll"
Return
Create_Tiles:
Create Bitmap 1,800,600
Rem Create 20 different random shaded tiles
For N=1 To 20
CLS RGB(255,255,255)
Ink RGB(0,0,0),0: Box 1,1,31,31
C=Rnd(155)+100
Ink RGB(C,C,C),0: Box 1,1,30,30
Get Image N,0,0,32,32: Rem Store tiles in images 1 to 20
Next N
Set Current Bitmap 0
Delete Bitmap 1
Rem Place Random Tiles Into The Tiles Array. This would normally be done manually
Rem with a level editor for a game.
Rem For This Example, We'll Also Limit The Landscape To Being 10,000 Tiles Wide
For LandscapeX=0 To ScrnTileWidth-1
For LandscapeY=0 To 17
Tiles(LandscapeX,LandscapeY)=Rnd(19)+1
Next LandscapeY
Next LandscapeX
Return
Setup:
Set Display Mode 800,600,16
Sync On: Sync Rate 60: CLS 0
Randomize Timer()
Dim Tiles(50000,17)
XTileOffset=0
XPixelOffset=0
ScrollSpeed=2
ScrnTileWidth=10000: Rem Number of tiles across on this level
Return
It creates it's own media randomly and you use the left and right cursor keys to scroll.
It's not 100% glitch-free on my system because I have inexpensive TFT monitors with fairly slow refresh rates. It should be fine on a proper monitor. Try it and let me know.
It creates random coloured tiles and simply stores them randomly in an array. You would need to create a level editor so you decide where to place the tiles you create yourself, but the scrolling would be the same.
TDK_Man