B3D Newb help needed here on 'types'
Blitz3D Forums/Blitz3D Programming/B3D Newb help needed here on 'types'
| ||
I've read most all the programs that comes with B3D, and I noticed that most of them use 'global', 'const', and 'type'. Ok, the only one that throws me is 'type / field'. Could someone please sum it up in easy to understand lingo for me? thanx all |
| ||
Well the type is a the way you define custom data types. You define it with a name, IE: Type MyType. MyType is the name of your new data type. You then define what that data type contains with "fields". IE: Type MyType Field Name$; <- a name for it end type Now, to create a new instance of this data type, you do something like this. InstanceName.TypeName and an example using our MyType data type: AnInstance.MyType = New MyType <- see how it creates a "NEW" mytype? :) To access fields in the type isntance (Namely the name field). You would do this to that newly created instance of the MyType data type: AnInstance\Name = "A super duper MyType instance!!!". Same deal to access the data in that instance. Global AName$ AName = AnInstance\Name Hope this helps. |
| ||
Actually it does help, it will take me a bit to digest it and play around with some samples. thanx for your time. |
| ||
Once you get through that bit, post again for more help, cause there's some REALLY weird stuff about Types hiding there, waiting to bite you in the butt. |
| ||
there's some REALLY weird stuff about Types hiding there, waiting to bite you in the butt. Yes , whatever you do - don't feed them after dark ! |
| ||
Newbies: Definitive Guide to Types: http://www.blitzcoder.com/cgi-bin/articles/show_article.pl?f=mutteringgoblin09232002232208.html Other goodies: http://www.blitzcoder.com/articles.shtml |
| ||
Scenario When I built my first game I loaded 20 enemies using copyentity. I thought this was cool until I had to then specify what should happen for each when it came to animation, shooting, being shot etc. With types I could load 20 enemies but was able to define the actions once for the type. Each enemy then inherited these parameters and acted on them individually depending on the situation. ie if I shot one of them he would fall over and make the sounds etc, but all others would remain unaffected. It meakes everything easier to manage... |