Here's a snippet adapted from the snowboarding example by Phaelax that I found on the Code Snippets board.
Gosub Setup
Do
rem Control player with arrow keys
if upkey()=1 then x#=newxvalue(x#,a#,7): z#=newzvalue(z#,a#,7)
if leftkey()=1 then a#=wrapvalue(a#-5.0)
if rightkey()=1 then a#=wrapvalue(a#+5.0)
dx#=curvevalue(x#,dx#, 15.0)
dz#=curvevalue(z#,dz#, 15.0)
da#=curveangle(a#, da#, 10.0)
dec y#,4.0
if y# < get ground height(1,dx#,dz#)+1.0
y#=get ground height(1,dx#,dz#)+1.0
endif
Set Camera To Follow dx#,y#,dz#,Object Angle Y(6),20,y#+15,5,0
point camera dx#,y#+5,dz#
Gosub Calculate_Tilt
position object 6,dx#,y#,dz#
yrotate object 6,da#
rotate object 1,wrapvalue(length#),0,wrapvalue(width#)
if dx#>5000 or dx#<0 or dz#>5000 or dz#<0
dx#=500:dz#=500
x#=500:z#=500
endif
sync
Loop
End
Calculate_Tilt:
rem find the ground height at each corner of the snowboard
temp_angle#=curveangle(a#, da#-20, 10.0)
front_left_x#=newxvalue(dx#,wrapvalue(temp_angle#),7.5)
front_left_z#=newzvalue(dz#,wrapvalue(temp_angle#),7.5)
front_left_height#=get ground height(1,front_left_x#,front_left_z#)
temp_angle#=curveangle(a#, da#+20, 10.0)
front_right_x#=newxvalue(dx#,wrapvalue(temp_angle#),7.5)
front_right_z#=newzvalue(dz#,wrapvalue(temp_angle#),7.5)
front_right_height#=get ground height(1,front_right_x#,front_right_z#)
temp_angle#=curveangle(a#, da#+20, 10.0)+180
rear_left_x#=newxvalue(dx#,wrapvalue(temp_angle#),7.5)
rear_left_z#=newzvalue(dz#,wrapvalue(temp_angle#),7.5)
rear_left_height#=get ground height(1,rear_left_x#,rear_left_z#)
temp_angle#=curveangle(a#, da#-20, 10.0)+180
rear_right_x#=newxvalue(dx#,wrapvalue(temp_angle#),7.5)
rear_right_z#=newzvalue(dz#,wrapvalue(temp_angle#),7.5)
rear_right_height#=get ground height(1,rear_right_x#,rear_right_z#)
rem calculate the amount to angle-tilt snowboard
length#=((rear_left_height#-front_left_height#)+(rear_right_height#-front_right_height#))/0.6
width#=((front_right_height#-front_left_height#)+(rear_right_height#-rear_left_height#))/0.2
Return
Setup:
set display mode 800,600,32
sync on
autocam off
hide mouse
backdrop on
color backdrop 0
Rem Matrix
make matrix 1,5000,5000,50,50
Randomize Matrix 1,55
update matrix 1
Rem Objects
make object box 1,4,2,8
color object 1, RGB(255,0,0)
make object cube 6, 1
glue object to limb 1,6,0
x#=100.0: z#=100.0
a#=get ground height(1,dx#,dz#)+1.0
Return
TDK_Man