(AGK version: 108.24)
Submitted: 2014-12-15 17:02:00
// this example should work with AGK V1 and V2

// use wasd or the on screen joystick to move the sphere

// make a sphere and position it
CreateObjectSphere(1,10,12,12)
SetObjectPosition(1,0,0,40)


// make a box (will automatically be positioned at 0,0,0)
CreateObjectBox(2,5,5,20)

// create a directional light (delete it and you'll find out how rubbish everything looks without it)
CreateLightDirectional(1,1,-1,0,255,255,255)

// position and orientate the camera
SetCameraPosition(1,0,200,-100)
SetCameraLookAt(1,0,0,0,0)

// main loop
do

	// get player input
	joystick_x# = GetJoystickX()
	joystick_y# = GetJoystickY()

	// move the sphere based on the player input
	MoveObjectLocalX(1,joystick_x#*2)
	MoveObjectLocalZ(1,joystick_y#*-2) // multiplied by -2 so the sphere moves in the direction the joystick is pushed

	// make the box look at the sphere
	SetObjectLookAt(2,GetObjectX(1),GetObjectY(1),GetObjectZ(1),0)

	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.