Little problem understanding types...

Blitz3D Forums/Blitz3D Programming/Little problem understanding types...

ChrML(Posted 2003) [#1]
I have some problems understanding Types. I know that they are declared like this:

Type TypeName
Field myvar1, myvar2
End Type

, and I know how to access them, but if this is like creating chairs, etc...where do script the Types? If I for example wants to create lots of cars which "lives in it's own world", and does what myvar1, and myvar2 says, where do I script the car that can be created with TypeName with variable myvar1, and myvar2?


Gabriel(Posted 2003) [#2]
Read this :

http://www.blitzcoder.com/cgi-bin/articles/show_article.pl?f=gamekrylar10192000.html

And then read this :

http://www.blitzcoder.com/cgi-bin/articles/show_article.pl?f=mutteringgoblin09232002232208.html


All will become clear.


ChrML(Posted 2003) [#3]
That's the part I do understand (just read it). I do understand how I can declare the types, create new ones with the specific variablevalues, but how can I for example create 100 chairs (with all the coordinates, and stuff), if the chairs aren't loaded anywhere? That's what I can't understand.


Gabriel(Posted 2003) [#4]
I find it very hard to believe you read all of both those articles and took it all in during the twelve minutes since I posted. In any case, you haven't take it all in, and you really need to read them through again, carefully. The explain it far better than I could.


(tu) sinu(Posted 2003) [#5]
"but how can I for example create 100 chairs (with all the coordinates, and stuff), if the chairs aren't loaded anywhere? That's what I can't understand."

something like this?

for i = 0 to 99

c.chair = new chair

c\Xpos = rnd(-100,100)
c\Zpos = rnd(-100,100)
c\name$ = "chair" +str(i)

next

however if you want to create each xpos and ypos manually you would need to do them manually or use an editor or maybe from some data.


ChrML(Posted 2003) [#6]
But where is LoadMesh("Chair.x")?, that makes the chair appear? Currently I'm using arrays to have many objects, and still control them.


Shambler(Posted 2003) [#7]
Put another field into the type, for example

Field ChairMesh

then do a

c\ChairMesh=LoadMesh("Chair.x")

or load a chairmesh into another mesh and do a CopyEntity for each one.


mouss38(Posted 2003) [#8]
when I need to update all of my types, i use this code

For Type.Type = each Type
[update code]
Next

But when I need to update one Type of this collection in particular, I select the type by one of its field, for instance :

For Type.Type = each Type
If Type\Name$ = "mark sibly"
[update code]
Endif
Next

My Level Editor and my Game are built on this principle and all seem to be perfect.