// this example should work on AGK V1 and V2
// set the resolution
SetVirtualResolution(800,480)
// create a sphere
CreateObjectBox(1,20,20,20)
// create a sprite, size it and color it green and make it transparent
CreateSprite(1,0)
SetSpriteSize(1,20,20)
SetSpriteColor(1,0,255,0,150)
// create a directional light (to make the box look better)
CreateLightDirectional(1,1,-1,1,255,255,255)
// position and point the camera
SetCameraPosition(1,0,150,-300)
SetCameraLookAt(1,0,0,0,0)
do
// this bit of code makes the box move in a circle, centered on the 0,0,0 point
SetObjectPosition(1,0,0,0)
RotateObjectLocalY(1,1)
MoveObjectLocalZ(1,50)
// translate the object 3D coordinates to 2D screen coordinate
screen_x# = GetScreenXFrom3D(GetObjectX(1),GetObjectY(1),GetObjectZ(1))
screen_y# = GetScreenYFrom3D(GetObjectX(1),GetObjectY(1),GetObjectZ(1))
// position the green sprite on the box (by not specifify on offset the sprite will automatically be position by its centre)
SetSpritePositionByOffset(1,screen_x#,screen_y#)
sync()
loop
Help make AGK better by submitting an example for this command! (All examples are subject to approval)