(AGK version: 108.21)
Submitted: 2014-12-15 08:04:56
// 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 colour 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 nicer)
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 specifying on offset the sprite will automatically be position by its centre)
	SetSpritePositionByOffset(1,screen_x#,screen_y#)

	sync()

loop
(AGK version: 2)
Submitted: 2020-01-21 17:31:00
// Draw a 2d line joining 3D objects
// set the resolution
SetVirtualResolution(800,480)
// create 2 cubes
CreateObjectBox(1,20,20,20) // the moving cube
CreateObjectBox(2,20,20,20) // the stationary cube
SetObjectPosition(2,20,50,60)
// position and point the camera
SetCameraPosition(1,0,150,-300)
SetCameraLookAt(1,0,0,0,0)


do

        // this bit of code makes object 1 move in a circle, centered on the 0,0,0 point
        SetObjectPosition(1,0,0,0)
        RotateObjectLocalY(1,1)
        MoveObjectLocalZ(1,50)

        // translate the 2 cubes 3D coordinates to 2D screen coordinate
        screen_x# = GetScreenXFrom3D(GetObjectX(1),GetObjectY(1),GetObjectZ(1))
        screen_y# = GetScreenYFrom3D(GetObjectX(1),GetObjectY(1),GetObjectZ(1))
        screen_xx# = GetScreenXFrom3D(GetObjectX(2),GetObjectY(2),GetObjectZ(2))
        screen_yy# = GetScreenYFrom3D(GetObjectX(2),GetObjectY(2),GetObjectZ(2))
        
        // draw 2d line connecting the two 3D objects
        drawline(screen_x#,screen_y#, screen_xx#,screen_yy#,50,255,255)

        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.