This will help a lot of noobs! I made another version of your code, maybe a simpler one that has the REM command in it? It introduces the Curveangle command too, which keeps the value between 0 and 360 degrees.
rem Setup the game by allowing the game to refresh the screen using the SYNC command at a rate of 100.
sync on
sync rate 100
rem Stop the camera from moving each time an object is created
autocam off
rem Create a cube to control
make object cube 1,10
rem Rotate the camera to a good angle
xrotate camera 90
rem Put the camera in place for the demo
position camera 0,60,0
rem Begin the Loop
do
rem Set the Speed that the cube is trying to reach back to 0.
TargetSpeed#=0
rem If you press the up arrowkey, then make the target speed go up to 1 for forwards.
if upkey() then TargetSpeed#=1
rem If you press down, make it go to -1 for backwards.
if downkey() then TargetSpeed#=-1
rem If you press the left arrowkey, decrease the angle that the cube is trying to reach, thus turning it left.
if leftkey() then TargetAngle#=TargetAngle#-5
rem If you press the right arrowkey, then increase the angle that the cube is trying to reach, thus turning the cube right.
if rightkey() then TargetAngle#=TargetAngle#+5
rem Print the Current Angle.
set cursor 0,0
print AngleSpeed#
rem Make the speed and angle values try to reach their new targets. They will take ten steps before they reach the Target value. That's what that 10 is for :-)
rem Do it for the speed value using the Curvevalue command.
UpSpeed#=Curvevalue(TargetSpeed#,UpSpeed#,10)
rem Do it for the angle value using the curveangle command. Curveangle keeps the value between 0 and 360 degrees, while Curvevalue does not.
AngleSpeed#=Curveangle(TargetAngle#,AngleSpeed#,10)
rem Move the cube at our new speed value.
move object 1,UpSpeed#
rem Rotate our cube to the correct angle.
yrotate object 1,AngleSpeed#
rem Refresh/Update the screen
sync
rem End of the loop
loop
Without the REMS:
sync on
sync rate 100
autocam off
make object cube 1,10
xrotate camera 90
position camera 0,60,0
do
TargetSpeed#=0
if upkey() then TargetSpeed#=1
if downkey() then TargetSpeed#=-1
if leftkey() then TargetAngle#=TargetAngle#-5
if rightkey() then TargetAngle#=TargetAngle#+5
set cursor 0,0
print AngleSpeed#
UpSpeed#=Curvevalue(TargetSpeed#,UpSpeed#,10)
AngleSpeed#=Curveangle(TargetAngle#,AngleSpeed#,10)
move object 1,UpSpeed#
yrotate object 1,AngleSpeed#
sync
loop