(AGK version: 108.21)
Submitted: 2014-12-14 08:27:37
// note: this example should work with AGK 108.21 and AGK V2

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

// create a direction light and some boxes and spheres to act as a "map"
// CreateLightDirectional(1,-1,-1,1,255,255,255)
for i = 1 to 4
	createObjectBox(i,50,50,50) //create the box
next i
for i = 5 to 6
	CreateObjectSphere(i,50,12,12)
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

// color and position the spheres
SetObjectColor(5,255,0,0,255)
SetObjectPosition(5,0,150,0)  //above the camera
SetObjectColor(6,0,255,0,0)
SetObjectPosition(6,0,-150,0)  //below 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
	RotateCameraGlobalY(1,joystick_x)
	RotateCameraGlobalX(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.