Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by dahl

Can entities be coded in such a way that they will recognize each other. ex:
RedGem, BlueGem, GreenGem. 3 RedGems touching, causes an effect outlined w/i the entity. but 2 RedGems 1 BlueGem does nothing. The best i could come up with was checkAgainst, but that only works for "TYPE", right? I am hoping someone out there knows of a way this might be done on the Entity level. any help would be great. thanks for your time!

1 decade ago by fugufish

at a very basic level, you can always set a special property (blue,red,green,etc) for each entity. Run checkAgainst when two entities collide, and try to retrieve that property. Then put code for each property (if blue then.... else )

1 decade ago by quantum

Yes, this is what I did for Klax - Score Attack.

Each tile has a colour property (e.g. 1 for blue, 2 for green, etc). This enables you to write a routine that searches for runs (e.g. 3+) of the same colour in your (array) representation of the "game board".

1 decade ago by dahl

Hey guys that was awesome! Between the two of you and Dom this is what I got:
update: function() {
   this.overlappingEntities.push = [];
   this.parent();
}

check: function( other ) {
     this.overlappingEntities.push( other instanceOf EntityRedGem );
     
     if(this.overlappingEntities.length >= 2) {
     // perform action
   }
}

You guys were great, thank you so much!

1 decade ago by Kxen

Hey dahl,

Is that really the correct code? I can see "instanceOf" is written incorrectly (I don't think it should be a capital O) and I can't get it to work so I'm starting to think something more is wrong with it.

Thanks.
Page 1 of 1
« first « previous next › last »