The Daily Click ::. Forums ::. Klik Coding Help ::. An object collides with itself?
 

Post Reply  Post Oekaki 
 

Posted By Message

HorrendousGames

Sourpuss

Registered
  31/10/2009
Points
  481

VIP MemberEvil klikerGame Of The Week Winner
6th February, 2010 at 22:57:54 -

I'm in the dreaded "I need to detect a collision between an active and a copy of active" situation. Anyone have an idea on how to rectify this situation?

 
/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/
That Really Hot Chick
now on the Xbox Live Marketplace!

http://marketplace.xbox.com/en-US/Product/That-Really-Hot-Chick/66acd000-77fe-1000-9115-d80258550942

http://www.create-games.com/project.asp?view=main&id=2160

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
6th February, 2010 at 23:25:48 -

Hey John, long time no see! Would you be able to share some details about the setup? Solutions can be a bit different depending on what you're doing.

 

  		
  		

Tokinsom



Registered
  22/11/2009
Points
  25
6th February, 2010 at 23:28:16 -

I'm having this same issue myself D: The closest I've got to fixing it is, for one: using spread values, loop index, and ID's. Then on the loop, compare the 2 object ID's and make sure they are different, not equal. Worth a shot.

 
n/a

HorrendousGames

Sourpuss

Registered
  31/10/2009
Points
  481

VIP MemberEvil klikerGame Of The Week Winner
7th February, 2010 at 01:13:04 -

Long time no see indeed! My internet was shut off for a while, so I've neglected appearing here.

Anyways, the situation is I have an area that needs have objects appear randomly upon it, but they shouldn't touch each other, and putting them on a grid doesn't make it look random enough. All the objects basically start off as 80x80 squares, that once the set up is finished they all change into the form that they need to be in. I set it up to say at the start of the frame start a loop 10+Random(10) times. On each of those loops, it creates a square, puts the value of the loop in an value on the square and sets it to random position in a zone (regardless of whether it will collide with another square or not). After that, the script checks to see if a flag is off, if it is, it sets it on and starts a loop that executes as many times as there are squares. Then during each loop it checks to see if the previously entered value equals the loop index, and there it should do a check to see if it collides with another square. If it does, it turns the flag off again and breaks the loop. after all of it, there is a check to see if the flag is still on, if it is, it start the morph phase (which works).

 
/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/
That Really Hot Chick
now on the Xbox Live Marketplace!

http://marketplace.xbox.com/en-US/Product/That-Really-Hot-Chick/66acd000-77fe-1000-9115-d80258550942

http://www.create-games.com/project.asp?view=main&id=2160

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
7th February, 2010 at 04:43:30 -

Here are two examples that I made in 07 and 08 that show you how to differentiate between duplicates. Basically it's a matter of saving their fixed ID somewhere and retrieving it later:

Follow the active infront - all objects are the same, including the head:
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Main=10038&Number=69518#Post69518

When two duplicates overlap with the same Alt A they are both destroyed. (Mouse click to move, mouse over to see Alt A)
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Main=18586&Number=131439#Post131439

 
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

HorrendousGames

Sourpuss

Registered
  31/10/2009
Points
  481

VIP MemberEvil klikerGame Of The Week Winner
7th February, 2010 at 06:17:07 -

Ahah, I got it. The sad thing is that it was because I put it in a loop for some reason it was acting up.

I really like those examples you posted Andy, in fact the only code that I needed for this was square collides with square then pick one. That's it. I guess that when you tell MMF2 to pick an object during a loop, for some reason it just likes to skip that step? I don't know.

The one gripe I had was that since it isn't in a loop, there is always the chance of that awkward square(s) that cant seem to find a spot. To rectify this, each time a square bounced off of another square or invalid object (such as a backdrop) it add to a value. When that value reaches a certain point, it just destroys the square, and that is topped off by increasing the starting amount of squares.

Thanks a lot for the ideas and help.

 
/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/
That Really Hot Chick
now on the Xbox Live Marketplace!

http://marketplace.xbox.com/en-US/Product/That-Really-Hot-Chick/66acd000-77fe-1000-9115-d80258550942

http://www.create-games.com/project.asp?view=main&id=2160

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
7th February, 2010 at 13:09:06 -

I'm glad that you found it useful

 
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
   

Post Reply



 



Advertisement

Worth A Click