123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|627|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> Blitz types....

Wed, 09 Jul 2008, 14:24
Orion Pax
When you create types and then create a new instance, is that pointer for ALL of that ONE type or can you use another variable to create another hole set of that same type.

Can you have more than one set of that type?
Wed, 09 Jul 2008, 14:47
Jayenkai
No, or yes, or no...

When you initially create and set to a variable..
This.object
Then This = Only that one..
It's not until you change what This points to that it's content changes.

So, if you make Array[100].Object, and place each object into it's own slot, then.. Sure, you could then have Array2[100].Object, and call those a second set.

But no, if you then For Each the objects, it'll use "Object-All", not "Array-Set" as the list selector.

If you get what I mean.

You can either Set up ObjectA and ObjectB types, or..

Type Object
Field Set
Field x,y,whatever
End Type

And then use This\Set to decide which set it belongs in, and what you're going to do with it.
(But that means you're going to do at least one "If/Select" for everything, just to see which set it's in..)

-=-=-
''Load, Next List!''
Wed, 09 Jul 2008, 15:34
Orion Pax
so im better off just creating a different type for each set. So if I want an asteroid to blow up into a random set of 3-5 medium asteroids then have each of those blow up into a random set of 3-5 small asteroids. I just might as well then. it would probably make it easier for the collision detection and moving them.
Thu, 10 Jul 2008, 16:58
Scherererer
you shouldn't need separate type lists for all the sizes of asteroids anyway. You can just add a field like "field asteroid_Type" and then make a set of global constant variables "aT_small=0, aT_medium=1, aT_large=2..etc.." and just change its behavior based on the type of asteroid. plus, for collision detection, you can set them to different EntityType's based on size or something.

-=-=-
YouTube Twitter
Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus
Thu, 10 Jul 2008, 17:29
JL235
This is where inheritance and polymorphism fixes the problem. An Asteroid class with several subclasses: SmallAsteroid, MediumAsteroid and BigAsteroid You then only need the one list of Asteroids which contains instances of the subclasses.
Thu, 10 Jul 2008, 18:04
mike_g
Heres an example of how to implement inheritance and polymorphism in Blitz in case you're interested. I dident write it myself. The comments kind of explain whats going on:


Thu, 10 Jul 2008, 20:23
Orion Pax
I get it a bit. Basically I am saving the address of the list to a variable. Then moving it back when I need that list again? So once I am done working with 1 list I can convert it to an address and create my other set of asteroids with the same type and then do the same for each one and convert it over as well.....

I guess thats what it means....am I making sense?
Thu, 10 Jul 2008, 22:33
Scherererer
Handle and Object are the two coolest undocumented commands in the existence of the blitz language. Well, maybe that and [].

-=-=-
YouTube Twitter
Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus
Thu, 10 Jul 2008, 23:19
Jayenkai
Handle and Object?!

*Goes hunting*
Becomes baffled..

Some day I'll probably find a use for all of that!

-=-=-
''Load, Next List!''
Fri, 11 Jul 2008, 18:39
Forklift_Fred
Sounds useful but I wish people wouldn't write such over complicated examples

I may read through it properly when I actually have time...

-=-=-
Come rain or shine...
Fri, 11 Jul 2008, 19:19
Scherererer
In the past, I've used it to reference one type from within another. Think of like, pikman for example: you've got one guy with a bunch of little pikman following him around; so you'd reference all the pikman as handles from the space man's type as a field.

-=-=-
YouTube Twitter
Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus
Sat, 12 Jul 2008, 11:23
9572AD
Of course if you use BlitzMax it's all different


-=-=-
All the raw, animal magnetism of a rutabaga.
Sun, 13 Jul 2008, 11:49
Forklift_Fred
Found a much simpler Handle and Object example/explanation on BlitzBasic.com (at the bottom of the page)

"Ross C"


This code creates 6 weapon objects in a type collection. It saves the handle to the 4th type object. Then at the end, jumps back to the 4th object by setting w.weapon to the w_handle (handle of the 4th weapon)

What this means is you can store these in an array. For instance, store all the handles to your weapons. When you want a particular weapon, 5 for instance, get the 5th handle in the array and plug it into



weapon - being the type collection
Object - being the Blitz command for this process
handle_array(5) - being the 5th handle in the array you created.

Other uses of this are, storing the handle inside the EntityName() of an entity.



This way, when ever say you shoot an entity, and you use linepick, for example.

You get the picked entity, the one you just shot. You grab that entities EntityName(). This contains the handle to the type object it's stored in. You can now modify that enemies health and such.



This shows that it is like a bookmark system, which is what I thought but it wasn't clear before.

-=-=-
Come rain or shine...
Sun, 13 Jul 2008, 12:25
flying_cucco
As an aside, and for our snakey friends, Handle and Object are ItemInList and IndexedItem respectively.