Here's an example using a wall.
Rem Walled Matrix Example By TDK_Man Sept 2007
Gosub Setup
Do
CX#=Camera Angle X(): CY#=Camera Angle Y(): CZ#=Camera Angle Z()
CY#=Wrapvalue(CY#+mousemovex())
CX#=Wrapvalue(CX#+mousemovey())
Rotate Camera CX#,CY#,CZ#
If MouseClick()=1 Then Move Camera 10
If MouseClick()=2 Then Move Camera -10
CPX# = Camera Position X(): CPZ# = Camera Position Z()
CGh# = Get Ground Height(1,CPX#,CPZ#)+8
rem CGh# = Camera Position Y()
Rem **********************************
Rem ***** OBese87's Code Snippet *****
Rem **********************************
If CPX# < 30.0 Then CPX# = 30.0
If CPZ# < 30.0 Then CPZ# = 30.0
If CPX# > 4970.0 Then CPX# = 4970.0
If CPZ# > 4970.0 Then CPZ# = 4970.0
Position Camera CPX#,CGh#,CPZ#
Sync
Loop
End
Rem **************************************************
Rem Procedures
Rem **************************************************
Rem Smooth Matrix
Smooth:
Rem Averages matrix heights to remove jagged edges
for Z=0 to 50
for X=0 to 50
P0#=Get Matrix Height(1,X,Z): Rem Current point height
Rem Get 4 adjoining points heights (if they exist)
If Z-1>=0
P1#=Get Matrix Height(1,X,Z-1)
Else
P1#=P0#
Endif
If X+1<=TilesX
P2#=Get Matrix Height(1,X+1,Z)
Else
P2#=P0#
Endif
If Z+1<=TilesZ
P3#=Get Matrix Height(1,X,Z+1)
Else
P3#=P0#
Endif
If X-1>=0
P4#=Get Matrix Height(1,X-1,Z)
Else
P4#=P0#
Endif
Average#=(P0#+P1#+P2#+P3#+P4#)/5: Rem Av height of other points
RHeight#=Average#
Set Matrix Height 1,x,z,RHeight#
Next x
Next z
Update Matrix 1
Return
Rem Program Initialisation
Setup:
Set Display Mode 800,600,32
Sync On: Sync Rate 0: CLS 0: Sync
AutoCam Off
Set Camera Range 1.0, 8000.0
Hide Mouse
Set Ambient Light 80
Randomize Timer()
Fog On
Fog Color RGB(0,30,0)
Fog Distance 5000
Create Bitmap 1,800,600
Rem Matrix Texture
Ink RGB(0,130,0),0
Box 0,0,256,256
For N=1 To 5000
Ink RGB(0,Rnd(250)+50,0),0
Dot Rnd(1024),Rnd(1024)
Next N
Blur Bitmap 1,2
Get Image 1,0,0,256,256
Rem Wall Texture
CLS RGB(200,200,200): Ink RGB(90,90,100),0
For N=0 To 3: Circle 6,6,4-N: Next N
For N=0 To 3: Circle 123,6,4-N: Next N
For N=0 To 3: Circle 6,59,4-N: Next N
For N=0 To 3: Circle 123,59,4-N: Next N
Box 6,2,124,63: Box 2,6,127,59
For N=1 To 4000
C=Rnd(200): Ink RGB(C,C,C),0: Dot Rnd(122)+4,Rnd(58)+4
Next N
Sync
Get Image 10,0,0,128,64
For Ny=0 To 15
For Nx=0 To 9
Paste Image 10,Nx*128-Offset,Ny*64
Next Nx
Inc Offset,64: If Offset=128 Then Offset=0
Next Ny
Delete Image 10
Blur Bitmap 1,1
Get Image 2,0,0,512,512
Set Current Bitmap 0
Delete Bitmap 1
Make Matrix 1,5000,5000,50,50
Prepare Matrix Texture 1,1,1,1
Randomize Matrix 1,2000.0
For N=1 To 140
X=Rnd(46)+2: Z=Rnd(46)+2
Set Matrix Height 1,X,Z,2000.0
Next N
For N=1 To 30
Gosub Smooth
Next N
Normalise(1)
Update Matrix 1
Rem Create 4 Walls
WallY# = Get Ground Height(1,500,500)
Make Object Box 1,40,600,5000: Rem West Wall
Texture Object 1,2: Scale Object Texture 1,100,7
Position Object 1,0,WallY#,2500
Make Object Box 2,40,600,5000: Rem East Wall
Texture Object 2,2: Scale Object Texture 2,100,7
Position Object 2,5000,WallY#,2500
Make Object Box 3,5000,600,40: Rem South Wall
Texture Object 3,2: Scale Object Texture 3,100,7
Position Object 3,2500,WallY#,0
Make Object Box 4,5000,600,40: Rem North Wall
Texture Object 4,2: Scale Object Texture 4,100,7
Position Object 4,2500,WallY#,5000
Position Camera 500,8,500
rem Point Camera 500,1,500
Return
Rem **************************************************
Rem Functions
Rem **************************************************
Rem Add Smoothing Normals
Function Normalise(MatNum)
Rem By Lee Bamber From DB Example - Adds shaded areas to matrix to give depth
For z=1 to 50
For x=1 to 50
h8#=get matrix height(MatNum,x,z-1)
h4#=get matrix height(MatNum,x-1,z)
h#=get matrix height(MatNum,x,z)
h2#=get matrix height(MatNum,x,z)
x1#=(x-1)*25.0
y1#=h#
x2#=(x+0)*25.0
y2#=h4#
dx#=x2#-x1#
dy#=y2#-y1#
ax#=atanfull(dx#,dy#)
ax#=wrapvalue(90-ax#)
z1#=(z-1)*25.0
y1#=h2#
z2#=(z+0)*25.0
y2#=h8#
dz#=z2#-z1#
dy#=y2#-y1#
az#=atanfull(dz#,dy#)
az#=wrapvalue(90-az#)
nx#=sin(ax#)
ny#=cos(ax#)
nz#=sin(az#)
Set matrix normal MatNum,x,z,nx#,ny#,nz#
next x
next z
Update Matrix MatNum
EndFunction
This also uses the player position on the matrix, though you could use collision between the player and the wall, though in this case I don't think it's worth it.
TDK_Man