Types again

Blitz3D Forums/Blitz3D Beginners Area/Types again

Type Stars
   Field x#, y#, z#
   Field r, g, b
End Type

Global MyStars.Stars
SeedRnd Millisecs()

;  Here I can make 15 different stars each as it's own
;  individual object.  (types are just a linked list)

For count = 1 to 15
   MyStars.Stars = New Stars

   ; Give'm random coordinates
   MyStars\x# = Rnd(-100,100)
   MyStars\y# = Rnd(-100,100)
   MyStars\z# = Rnd(-100,100)

   ; Give'm random color
   MyStars\r = Rand(0,255)
   MyStars\g = Rand(0,255)
   MyStars\b = Rand(0,255)
Next

counter = 1

For MyStars.Stars = Each Stars
   Print "Star #" + counter
   Print "x: " + MyStars\x# + " y: " + MyStars\y# + " z: " + MyStars\z#

   ;  Same for print for color... here 

   counter = counter + 1
Next

waitkey()



This is a small example. Hope it helps. They're each separate objects tied together in a link list so you can use For/Each, First, Last, and Before commands to navigate through the list of objects (and Delete to get rid of them).