an array of objects?

BlitzMax Forums/BlitzMax Programming/an array of objects?

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.

It will depend what you want to do next but this works
Local circ:circle[10]
For t=0 To 9
	Circ[t] = Circle.create(Rnd(300),Rnd(300) , 30)
Next
Type Circle
	Field x
	Field y
	Field r
	Field r2
	Function create:Circle( px#, py#, pr# ) 
		Local Circle_:Circle = New Circle
		Circle_.x = px
		Circle_.y = py
		Circle_.r = pr
		Circle_.r2 = pr*pr
		Return Circle_
	End Function 
End Type

If you don't want to predefine the size of circ array then use a slice to increase it
Local circ:circle[]
For t = 0 To 9
	circ=circ[..len.circ+1]
	Circ[t] = Circle.create(Rnd(300) , Rnd(300) , 30)
	Print circ[t].x + " " + circ[t].y
Next