; ShadowColor Example
; -------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,5,-9
RotateEntity camera,25,0,0

; A directional sun; the shadow system selects it automatically
sun=CreateLight(1)
AmbientLight 70,75,85

; Bright sandy ground so the shadow tint is easy to see
ground=CreateCube()
ScaleEntity ground,10,0.1,10
PositionEntity ground,0,-0.1,4
EntityColor ground,220,205,170

; A crate and a pillar to cast shadows
crate=CreateCube()
PositionEntity crate,-2.5,1,4
EntityColor crate,210,150,80

pillar=CreateCylinder()
ScaleEntity pillar,0.7,2,0.7
PositionEntity pillar,2.5,2,5
EntityColor pillar,120,160,220

; Turn on the automatic shadow system
Shadows 1

; Default tint is black at strength 0.65
red#=0
green#=0
blue#=0
strength#=0.65
mood$="1 classic black"
angle#=0

While Not KeyDown(1)

    ; Number keys pick an artistic tint; [ / ] set the darkness
    If KeyHit(2) Then
        red=0
        green=0
        blue=0
        mood="1 classic black"
    EndIf
    If KeyHit(3) Then
        red=30
        green=45
        blue=90
        mood="2 cool night blue"
    EndIf
    If KeyHit(4) Then
        red=90
        green=55
        blue=25
        mood="3 warm sepia"
    EndIf
    If KeyHit(5) Then
        red=110
        green=20
        blue=110
        mood="4 alien purple"
    EndIf
    If KeyDown(26) And strength>0 Then strength=strength-0.01
    If KeyDown(27) And strength<1 Then strength=strength+0.01

    ; Tint the shadows and set their maximum darkness
    ShadowColor red,green,blue,strength

    ; Swing the sun so the tinted shadows sweep the ground
    angle=angle+0.3
    RotateEntity sun,55,angle,0

    TurnEntity crate,0,1,0

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"1-4: tint preset   [ ]: strength   Arrow keys: move camera   Esc: exit"
    Text 0,20,"ShadowColor "+red+","+green+","+blue+","+strength
    Text 0,40,"Preset: "+mood

    Flip

Wend

End
