terrain_AI():

    application.setCurrentUserScene ( "terrain_scene" )
    local cam1=application.getCurrentUserSceneTaggedObject ( "cam_1st_tag" )
    application.setCurrentUserActiveCamera ( cam1 )


onkeyboardkeyup():

    if kKeyCode == input.kKeyW then   -- command
       this.w ( false )
    elseif kKeyCode == input.kKeyS then
       this.s ( false )
    end
    
    if kKeyCode == input.kKeyA then
       this.a ( false )
    elseif kKeyCode == input.kKeyD then
       this.d ( false )
    end
    
    if kKeyCode == input.kKeyUp then   -- command
       this.up ( false )
    elseif kKeyCode == input.kKeyDown then
       this.down ( false )
    end

onkeyboardkeydown():

    if kKeyCode == input.kKeyW then   -- command
       this.w ( true )
    elseif kKeyCode == input.kKeyS then
       this.s ( true )
    end
    
    if kKeyCode == input.kKeyA then
       this.a ( true )
    elseif kKeyCode == input.kKeyD then
       this.d ( true )
    end
    
    if kKeyCode == input.kKeyUp then   -- command
       this.up ( true )
    elseif kKeyCode == input.kKeyDown then
       this.down ( true )
    end

onEnterFrame():

 
     local cam = application.getCurrentUserActiveCamera ( )
     local scene1= application.getCurrentUserScene ( )
     if this.w ( ) then 
        object.translate ( cam, 0, 0, -0.05, object.kLocalSpace  )
     elseif this.s ( ) then
        object.translate ( cam, 0, 0, 0.05, object.kLocalSpace  )
     end
     
     if this.a ( ) then 
        object.rotate ( cam, 0, 2, 0, object.kGlobalSpace  )
     elseif this.d ( ) then
        object.rotate ( cam, 0, -2, 0, object.kGlobalSpace  )
     end

     if this.up( ) then 
        object.rotate ( cam, 2, 0, 0, object.kLocalSpace  )
     elseif this.down ( ) then
        object.rotate ( cam, -2, 0, 0, object.kLocalSpace  )
     end
     
     local x,y,z = object.getTranslation ( cam , object.kGlobalSpace )
     object.setTranslation ( cam, x, scene.getTerrainHeight ( scene1, x, z )+1.5,z,object.kGlobalSpace )
