123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|554|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz Max -> Wave's tutorial questions

Fri, 11 Jun 2010, 09:15
lijap
I am back with more nooby questions! I was reading wave's tutorial to get started in blitzmax and I got lost in the eachin loops and types, can anyone try to help my stubborn mind understand? All help is much appreciated. If you find any links that could be helpful please include them.
Fri, 11 Jun 2010, 09:33
Mog
Link to said tutorials?

As for EachIn / Types, it's a little tricky. Imagine a type as a collection of variables that go into a list (Linked List) that can be iterated through for whatever means. Say you have an enemy. Usually Enemies comprise of multiple variables that you would either:

a) use a variable for each parameter - Enemy1health, Enemy2health, Enemy1Name... - Blah! It's a bad idea, since they're 'hard coded'.

b) have a series of arrays for enemy parameter - EnemyHealth[ID], EnemyName[ID]

Types are the best of both worlds. Like trying to make enemies above, it fits the bill for such an application because you can do this:



Notice how i called New TEnemy? That makes a new enemy object, with a collection of variables for you to use. If you call it again, you'll have another - which makes 2. But how do you recall this information? Through the usage of lists.



This puts both objects into the list called 'Enemylist', which you can then iterate through using... EachIn!



Since I added two objects above, it will print:



There's a few other nuances, but this is the usage of the two. Let me know if there's any more questions

-=-=-
I am Busy Mongoose - My Website

Dev PC: AMD 8150-FX, 16gb Ram, GeForce GTX 680 2gb

Current Project: Pyroxene
Fri, 11 Jun 2010, 09:42
lijap
ok soooo..... types are just a quicker way of making tons variables? Sorry for my ignorance . heres the url www.blitzbasic.com/Community/posts.php?topic=42519
Fri, 11 Jun 2010, 09:58
Mog
Yes, pretty much. Imagine a variable as a sheet of paper, while a type would be something of a book that you can create and delete on a whim.

-=-=-
I am Busy Mongoose - My Website

Dev PC: AMD 8150-FX, 16gb Ram, GeForce GTX 680 2gb

Current Project: Pyroxene
Fri, 11 Jun 2010, 10:03
lijap
Ok now that I know their purpose learning them will be (much) easier!