About types.... to...

Blitz3D Forums/Blitz3D Beginners Area/About types.... to...

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.

I think what confused me first was the similar name calling.

Player_typ and Player sound similar and at first sound like the same thing.

Kaisuo you could name the new instance of Player_typ anything you want such as Player, Person, Sprite, Thing-a-ma-jig. I tend to use something like thisPlayer to define the current instance because I think it makes more sense.

Global thisPlayer.Player_typ = New Player_typ
thisPlayer\X = 20
thisPlayer\Y = 20
thisPlayer\JumpHeight = 5.5
thisPlayer\Visible = false

so if your types were dogs it could look like:

Global thisDog.Player_typ = New Player_typ
thisDog\X = 20
thisDog\Y = 20
thisDog\JumpHeight = 5.5
thisDog\Visible = false


so:

for count = 1 to 1000
Player.Player_typ = New Player_typ
Player\X = 20
Player\Y = 20
Player\JumpHeight# = 5.5
Player\Visible = false
next

and you have 1000 instances of "Player" of type "Player_typ"


ACTUALLY, you have ONE instance of Player (the last one that was created) and 1000 instances of Player_typ's. In other words, the Player variable only points to the last instance that was created because you reused it over and over. If you wanted to have a seperate variable for each instance of Player_typ then you would have use an array (i.e. Player(1) or Player(284)) to keep track of each one.