// this example should work with AGK V1 and AGK V2
// use the wasd keys or the onscreen joystick to rotate the box
// make a box (automatically position at 0,0,0)
CreateObjectBox(1,20,40,60)
// create a directional light
CreateLightDirectional(1,-1,-1,0.5,255,255,255)
// position and orientate the camera
SetCameraPosition(1,0,100,-200)
SetCameraLookAt(1,0,0,0,0)
// initial rotation values
angle_x# = 0.0
angle_y# = 0.0
// main loop
do
// get joystick input
joystick_x# = GetJoystickX()
joystick_y# = GetJoystickY()
// calculate angles based on joystick input
angle_x# = angle_x# + joystick_x#
angle_y# = angle_y# + joystick_y#*-1
// restrict the angles between 0 and 360 degrees
if angle_x# < 0.0
angle_x# = angle_x# + 360.0
endif
if angle_x# > 360.0
angle_x# = angle_x# - 360.0
endif
if angle_y# < 0.0
angle_y# = angle_y# + 360.0
endif
if angle_y# > 360.0
angle_y# = angle_y# - 360.0
endif
// rotate the object
SetObjectRotation(1,angle_y#, angle_x#,0.0)
// print the angles to the screen
print(angle_x#)
print(angle_y#)
sync()
loop
Help make AGK better by submitting an example for this command! (All examples are subject to approval)