(AGK version: 108.21)
Submitted: 2014-12-14 08:02:11
// note: this example should work with AGK V1 108.21 onward and AGK V2

// use the wasd keys or the on screen joystick
// to rotate the box about the global X and Y axis

// create a direction light and a box to rotate (the light just makes it easier to see the box)
// the box will automatically be positioned at 0,0,0
CreateLightDirectional(1,-1,-1,1,255,255,0)
createObjectBox(1,10,10,50)

// position the light away from the box and then make the camera look at where the box is
SetCameraPosition(1,0,0,-200)
SetCameraLookAt(1,0,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()

	// rotate the box
	RotateObjectGlobalY(1,joystick_x)
	RotateObjectGlobalX(1,joystick_y)

	// print the box's angles to the screen
	print(getObjectAngleX(1))
	print(getObjectAngleY(1))
	print(getObjectAngleY(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.