(AGK version: 108.21)
Submitted: 2014-12-14 07:59:30
// note: this example should work with AGK 108.21 onward and AGK V2

// use the wasd keys or the on screen joystick
// to rotate the camera about its local X and Y axis
// this can be a little disorientating

// create a direction light and some boxes to act as a "map"
// CreateLightDirectional(1,-1,-1,1,255,255,255)
for i = 1 to 4
        createObjectBox(i,20,500,20) //create the box
next i

// color and position position the boxes
SetObjectColor(1,255,255,255,255)
setObjectPosition(1,0,0,150)  //in front of the camera
SetObjectColor(2,255,0,0,255)
setObjectPosition(2,150,0,0)  //to the right of the camera
SetObjectColor(3,0,255,0,255)
SetObjectPosition(3,0,0,-150)  //behind the camera
SetObjectColor(4,0,0,255,255)
SetObjectPosition(4,-150,0,0)  //to the left of the camera

// set the camera's initial position and rotation
SetCameraPosition(1,0,0,0)
SetCameraRotation(1,0,0,0)

// main loop
do

        // player input using the joystick commands so this demo will work on a keyboard or a touch screen
        joystick_x = GetJoystickX()
        joystick_y = GetJoystickY()

        // reset the camera's rotation to zero by pressing spacebar or the on screen button
        if getButtonPressed(1) =1
                SetCameraRotation(1,0,0,0)
        endif

        // rotate the camera
        RotateCameraLocalY(1,joystick_x)
        RotateCameraLocalX(1,joystick_y)

        // print the box's angles to the screen
        print(getCameraAngleX(1))
        print(getCameraAngleY(1))
        print(getCameraAngleZ(1))

        sync()
loop
Help make AGK better by submitting an example for this command!
(All examples are subject to approval)
Login to post an example of your own.