listing nearest entities to the camera

Blitz3D Forums/Blitz3D Beginners Area/listing nearest entities to the camera

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here is my code. What a horrible mess eh? Thanks everyone for the help.


Type listitem
    Field name$
    Field dist#
    Field id
End Type

Type enemy
    Field mesh
    Field name$
    Field id
End Type

For i = 1 To 50
    e.enemy = New enemy
    e\mesh = CreateCube()
    e\id = i
    PositionEntity e\mesh,Rnd(-5000,5000),Rnd(-100,100),Rnd(-5000,5000)
    e\name = "Enemy"
Next

Repeat
        ......

	For e.enemy = each enemy
		If EntityDistance(camera, e\mesh) < 1000
			this.listitem = New listitem
			this\name$ = e\name
			this\dist = EntityDistance (camera,e\mesh)
			this\id = e\id ;
			addtolist(this.listitem)
			Delete this
		EndIf
	Next

	Flip

Until KeyHit (1)

End

Function addtolist(this.listitem)
	
	Text 10,10,this\name+" - "+this\id+" - "+this\dist+Chr$(13)
	;Text3D(font2,-500,0,this\name+" - "+this\id+" - "+this\dist,0)
	
End Function