2 Small questions

Blitz3D Forums/Blitz3D Beginners Area/2 Small questions

Mordax_Praetorian(Posted 2004) [#1]
Hi, just 2 things I need clarifying

1) Are all Types global, and if not can I make them so the same way as variables?

2) Is it possible to store Arrays within Types?


tonyg(Posted 2004) [#2]
1) Types are not automatically global but you can make them global
e.g global enemy.bullet
2) Yep, but they're 'special' Blitz arrays.
Type ship
Field missiles[2]
They have a few limitations...
http://www.blitzcoder.com/cgi-bin/code/code_showentry.pl?id=thechange09052002191420&comments=no
You can also have types within types and arrays of types.
Blitzcoder has some articles and Learn to Program 2D Games in Blitzbasic has a good section on this subject.


Mordax_Praetorian(Posted 2004) [#3]
Thanks

so I should be setting the individul type elements as Global instead of the type itself?


Gabriel(Posted 2004) [#4]
so I should be setting the individul type elements as Global instead of the type itself?


Generally, they're referred to as instances. If by elements, you mean instances, yes.

EG:

Type Ball
  Field X#,Y#,Z#
End Type

Global BasketBall.Ball=New Ball


In the example, Ball is the type, and basketball is an "instance" of the type. Types are automatically global, and you can create, delete or reference new or old instances in any function or from the main body of your program. Instances are only global if you specifically declare them so, as Tony demonstrated.


Mordax_Praetorian(Posted 2004) [#5]
got it

thanks for the help

Blitz has a lot of new stuff in it for me, its much better than slow old Dark Basic


Agamer(Posted 2004) [#6]
Cool thought I would say hi as you are new, hope you enjoy your self! I would awnser your quesiton but thats be done, ok what to do now I know (posts)