Hi all. Can someone please tell me how to make the ambient light brighter or darker depending where the sun / moon is positioned?
Here's the code:
`Sun Moon
`sunmoon3.dba
`======================
sync on
sync rate 60
set ambient light 100
autocam off
set camera range .1,1000000
make object sphere 100,10000,25,25
cls rgb(102,102,255)
get image 1,0,0,1,1
texture object 100,1,1
set object cull 100,0
make object sphere 20,10
make object sphere 21,10
make object cube 2,10
set object light 2,0
position object 2,25,1,-250
yrotate camera -90
global speed#
speed#=250
xrotate camera 10
fix object pivot 2
global cspeed#
cspeed#=500
do
position object 100,object position x(2),object position y(100),object position z(2)
move object 2,(keystate(17)-keystate(31) or upkey()-downkey())*0.5
turn object left 2,(keystate(30)-keystate(32) or leftkey()-rightkey())*0.5
oldspace=space
space=spacekey()
if oldspace<>space and space<>0
yrotate object 2,0
endif
`Record the camera's position before you put it where you want it.
WhereItWasBeforeX#=camera position x()
WhereItWasBeforeY#=camera position y()
WhereItWasBeforeZ#=camera position z()
`Record the camera's angle before you put it where you want it. The Wrapvalue() command just keeps the angle measure between 0 and 360 degrees. For example, 365 degrees would become 5 degrees, since they're both the same thing.
WhereItWasBeforeAngleX#=Wrapvalue( camera angle x() )
WhereItWasBeforeAngleY#=Wrapvalue( camera angle y() )
WhereItWasBeforeAngleZ#=Wrapvalue( camera angle z() )
if keystate(44)
inc cspeed#,0.5
endif
if keystate(45)
dec cspeed#,0.5
endif
if cspeed#>500 then cspeed#=500
if cspeed#<-10 then cspeed#=-10
`Put the camera where you want it to be.
position camera object POSITION X(2), OBJECT POSITION Y(2), OBJECT POSITION Z(2)
SET CAMERA TO OBJECT ORIENTATION 2
move camera -cspeed#
xrotate camera camera angle x()-90
move camera 7
xrotate camera camera angle x()+90
`Record this new position (where you WANT the camera to be) in some variables
WhereItShouldBeX#=camera position x()
WhereItShouldBeY#=camera position y()
WhereItShouldBeZ#=camera position z()
`Record the new angle in some variables
WhereItShouldBeAngleX#=Wrapvalue( camera angle x() )
WhereItShouldBeAngleY#=Wrapvalue( camera angle y() )
WhereItShouldBeAngleZ#=Wrapvalue( camera angle z() )
`Smoothly transition the camera from where it was before to where you want it to be. Record this "transitioned value" in new variables.
Smoothness#=5.0 `This is how much smoothness you want. 1 is no smoothness and higher numbers give you more and more smoothness.
`(The curvevalue command basically moves a value from one value to another within a certain number of steps. The more steps, the longer it takes for the value to get where you want it to be.
cx#=Curvevalue(WhereItShouldBeX#,WhereItWasBeforeX#,Smoothness#)
cy#=Curvevalue(WhereItShouldBeY#,WhereItWasBeforeY#,Smoothness#)
cz#=Curvevalue(WhereItShouldBeZ#,WhereItWasBeforeZ#,Smoothness#)
`Smoothly transition the camera's angle. I will use the Curveangle command here because it's better for angles than Curvevalue.
cax#=Curveangle(WhereItShouldBeAngleX#,WhereItWasBeforeAngleX#,Smoothness#)
cay#=Curveangle(WhereItShouldBeAngleY#,WhereItWasBeforeAngleY#,Smoothness#)
caz#=Curveangle(WhereItShouldBeAngleZ#,WhereItWasBeforeAngleZ#,Smoothness#)
`Finally, put the camera in its place and rotate it based on the smooth transitions above.
position camera cx#,cy#,cz#
`i point the sun/moon at the player
point object 20,object position x(2),object position y(2),object position z(2)
point object 21,object position x(2),object position y(2),object position z(2)
` move the sun and moon objects
zangle# = wrapvalue(zangle#+0.2) ` increased rotation speed so I can see it
position object 20, object position x(2)+speed#*cos(zangle#), speed#*sin(zangle#), object position z(2)
position object 21, object position x(2)-object position x(20), -object position y(20), object position z(2)
set ambient light speed#*cos(zangle#)
center text screen width()/2, screen height()/2, "zoomed in/out "+str$(cspeed#)+" ft."
center text screen width()/2, screen height()/2+20, "hold z to zoom out"
center text screen width()/2, screen height()/2+40, "hold a to zoom in"
center text screen width()/2, screen height()/2+60, "press space to reset player rotation"
sync
loop
CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!