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.

Kaisuo: Types are one thing which baffled me initially. Try to think of them as a list of objects. So when you create a player Type you are really creating a list of players. So when you use the line p.player = New player you are really adding something to the list. Once an item is added to the list you can fill in it's variables. Like so:
Type player
	Field X, Y	; You can also place multiple fields on the same line!
	Field Jumpheight
	Field visible
End Type

p1.player = New player	; Add player 1 to the list
p2.player = New player	; Add player 2 to the list

p1\X = player1_startX : p1\Y = player1_startY
p2\X = player2_startX : p2\Y = player2_startY
Note that like all variables, p1 and p2 (as per my example) are not global, therefore cannot be used in functions (it will return a Null value). If you want to be able to refer to it at any time, add Global to the declaration (ie. Global p1.player = New player). The items in a type list, however, are ALWAYS global. If you havent specified a global variable you can still get the information in the list by doing the following.

upkey = KeyHit(200)
For my.player = Each player
	If upkey
		my\Y = my\Y - 8
	EndIf
Next