I'm seriously starting to question the quality of these DBP books...
ANYWAY, your problem is that you haven't defined the variable
direction, so it defaults to the value 0. I've restructured your code a little, and you'll see just before the
REPEAT command that I've defined the variable to start with the value 1.
rem setup screen
HIDE MOUSE
COLOR BACKDROP RGB(0,60,60)
sync on
sync rate 60
`create a textured cube
MAKE OBJECT CUBE 1, 75
POSITION OBJECT 1, 0, -20, -120
`position the camera
MOVE CAMERA -150
PITCH CAMERA DOWN 20
`initialise variables
direction = 1
`start the loop
REPEAT
`rotate the objects individually
YROTATE OBJECT 1, OBJECT ANGLE Y(1) + 1
`update ambient variable
Ambient = Ambient + direction
IF Ambient > 100
Ambient = 100
Direction = -1
ENDIF
IF Ambient < 0
Ambient = 0
Direction = 1
ENDIF
`set the ambient light
SET AMBIENT LIGHT Ambient
`update the ambient color variables
IF Red > 254
IF Green > 254
IF Blue > 254
Red = 0
Green = 0
Blue = 0
ELSE
Blue = Blue + 1
ENDIF
ELSE
Green = Green + 1
ENDIF
ELSE
Red = Red + 1
ENDIF
`set the ambient color
COLOR AMBIENT LIGHT RGB(Red,Green,Blue)
`display the ambient variable
TEXT 10, 10, "Ambient level: " + STR$(Ambient)
TEXT 10, 20, "Color: "+ STR$(Red)+","+ STR$(Green)+ ","+ STR$(Blue)
`update the screen
SYNC
UNTIL ESCAPEKEY() = 1
`clean up
SHOW MOUSE
END
Please make sure you indent your code correctly in the future (use the TAB key on your keyboard), it helps not only us but also you.
TheComet