objects of the same kind.

Blitz3D Forums/Blitz3D Programming/objects of the same kind.

ckob(Posted 2005) [#1]
Ok im having a dumb moment here, im currently working on a small puzzle game and in the game you select entities from a table and if the entity that is picked matches the previous picked entity's class then it would remove the two entities. I have it so I can detect which entity is picked and I can get the class from that entity but im unsure on how to tell it to hold that entity and wait for the second click and if second click matches remove the entities if it doesnt then clear the clicks and start over. I hope i explained this enough so someone can help me out.


Baystep Productions(Posted 2005) [#2]
Okay your classes are held in a type right?

Well if they are then you could do something invloving
Global click1.object
Global curclick

;Rest of code in the For loop for checking each one
If MouseHit(1)
  Select curclick
      Case 0
          click1=this
      Case 1
          If  click1\class=this\class Then Hurray!
  End Select
  curclick=Not curclick
EndIf


And the this part reflects the type you are checking, along with the click1.object part. They should match.

click1.object
this.object


octothorpe(Posted 2005) [#3]
The Pick commands return an entity, and the only custom information you can store in an entity is its Name. Store the "class" of the entity in EntityName. Either that, or set it to a Handle() to the object which is represented by that entity. If you have different types, prefix the EntityName with a string identifier so that you'll know which type of object you have a handle for.



EDIT: whoops, I need to learn to read:

I have it so I can detect which entity is picked and I can get the class from that entity


Use a variable to keep track of the previously picked entity. When an entity is picked, if there's no previous, assign the new entity to the previous; if there is a previous, compare their classes. If the classes are the same, remove both entities. Reset the previously picked entity variable to 0 (Null if you're using objects). See the main loop of the code above for an example of all this.


ckob(Posted 2005) [#4]
thanks guys ill check this out when I get home.