The Daily Click ::. Forums ::. Klik Coding Help ::. Checking if Specific Instances Overlap
 

Post Reply  Post Oekaki 
 

Posted By Message

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
1st November, 2009 at 21:43:04 -

I'm not sure if this is going to be possible, due to the way MMF2 handles duplicates and collisions, but I'll ask anyway...

Is there any way to generate a list of objects which overlap a specific object?
I'm talking about multiple instances of the same object here, using fine-collision.

I'd like to be able to specify an object by it's fixed value, and generate a list of the fixed values of the other objects it overlaps.

Anyone have any bright ideas?

 
n/a

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
1st November, 2009 at 22:27:20 -

The only thing I can think of at the moment is running a fastloop through all your objects and checking each one in turn. I'm sure there are more effecient ways, so consider this a starting point

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
1st November, 2009 at 22:51:38 -

Thanks. I'm sure I'll have to do that, but that isn't the problem.

The problem is, how do I specify two particular duplicate objects at the same time?

Obviously this wouldn't work:

+ ID# of ObjectType1 = 1
+ ID# of ObjectType1 = 2
+ ObjectType1 overlaps ObjectType1
-> Objects are overlapping


I know you can say:

+ Object overlaps Object
-> spread value 1 in Object

This seems to be the only way to differentiate between overlapping objects, but if A overlaps B, and C overlaps D, it will think that C and D overlap A. If that makes sense?

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
2nd November, 2009 at 08:59:50 -

I just made you an example. It uses a "detector" which is the same shape as the objects that you are testing for overlap. I'm not sure if this meets your requirements. The detector can be any shape. Give it a try and tell me what you think:

http://mfa.aquadasoft.com/view/1257152301-Overlapping_Actives_List_Assault_Andy

Mouse over to check for overlapping actives.

-------------- Below are some other examples that I have previously made which might also be useful to you:

Here is a post I made earlier this year on how to differentiate between two duplicates:

http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Main=18586&Number=131439

"This example shows one method of differentiating between two duplicates so that when two duplicates are overlapping each other a check can be run between them to see if they have the same AltValA. It works by temporarily saving their fixed IDs."

So if two objects with the same alt val overlap each other, it will destroy one of them.

--------
Here is another example I made in 2007 of how to differentiate between duplicates another way:
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Main=10038&Number=69518#Post69518

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
2nd November, 2009 at 12:53:52 -

Thanks a lot - I eventually came up with a solution myself, but I'll definitely see if yours is better.

Here's mine - it should be fastlooped to check every combination of object pairs.

+ Always
-> Object: Set Flag 0 to OFF
-> Object: Set Alterable Value A to 0

+ Fixed(Object) = Fixed of first selected object...
-> Object: Set Flag 0 to ON

+ Fixed(Object) = Fixed of second selected object...
-> Object: Set Flag 0 to ON

+ Object: Flag 0 is ON
+ Object: overlaps Object
-> Object: Spread value "1" in Alterable Value A

That way, all the objects will have a value of "0" except for the two selected objects. If they don't overlap, they will also both be "0". If they do overlap, one will be "1" and one will be "2". You can then get the fixed values of those two objects.

I now just need to figure how to make it efficient - eg. if I know that A overlaps B, I shouldn't need to check whether B overlaps A...

 
n/a
   

Post Reply



 



Advertisement

Worth A Click