Type Trouble

BlitzPlus Forums/BlitzPlus Beginners Area/Type Trouble

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.

if you wanted to make a type called "baddie":


type baddie
; this declares the type

field xpos#
field ypos#
field speed%
; these are the attributes that each instance of the type will have

end type


and then to make a few new instances of the type you can say:



for i = 1 to 10
anythingyoulike.baddie = new baddie
anythingyoulike\xpos = rnd(1,200)
anythingyoulike\ypos = rnd(0.1,10.333)
anythingyoulike\speed = rnd(1,55)
next



this makes a list of 10 instances of the type baddie, with random values for each attribute.


so now youve made a list of types. to cycle through each of them:

for john.baddie = each baddie

john\ypos = john\ypos+10
; moves each instance down 10 pixels

next



to access the first one of the list:

fred.baddie = first baddie


to access the last one in the list:
beatrice.baddie = last baddie



to access the third one in the list
jemima.baddie = first baddie
jemima.baddie = next baddie
jemima.baddie = next baddie




neil