(AGK version: 108.24)
Submitted: 2015-01-02 18:43:09
// this example should work with AGK V1 and V2

// the wasd keys or the onscreen joystick to alter the colour of the cube

// make a cube (it will be automatically positioned at 0,0,0)
CreateObjectBox(1,20,20,20)

// create a directional light (to make the cube look nice)
CreateLightDirectional(1,-0.75,-1,0.5,255,255,255)

// position and orientate the camera
SetCameraPosition(1,-40,40,-30)
SetCameraLookAt(1,0,0,0,0)

// set some initial colours
red = 127
green = 127
blue = 127

do

	// get player input
	joystick_x = GetJoystickX()*10
	joystick_y = GetJoystickY()*10

	// adjust colours based on player input
	red = red + joystick_x
	blue = blue + joystick_y

	// restrict colour values to between 0 (zero) and 255
	if red < 0
		red = 0
	endif
	if red > 255
		red = 255
	endif
	if blue < 0
		blue = 0
	endif
	if blue > 255
		blue = 255
	endif

	// set the colour of the cube
	SetObjectColor(1,red,green,blue,255)

	// print out the colour values to the screen
	print(red)
	print(green)
	print(blue)

	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.