Avoid Collision

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Avoid Collision

Post by Surbhit29 » Thu Aug 16, 2012 1:50 pm

I have two draggable objects. I want both the objects to move as I drag them but I don't want them to collide or get overlap. Also how is it possible to drag them inside another object limiting their path...?
For eg, I want to Drag two square inside a Circle but I don't want both the square to collide or to overlap. Also the path of the squares should be limited inside the circle.

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Avoid Collision

Post by shaosean » Thu Aug 16, 2012 4:23 pm

Check out the demo of Animation Engine.. Malte has pretty much covered everything in there and made a pretty simple API to use and will save you countless time units spent figuring it out yourself.. But that being said, take a look at the is within operator, the location property (this will be the center point of the object so you can use it to keep your objects on a path which you might sent using one of the draw tools) and the move command.. Now each of those has a list of "see also" that you should check out.. After learning those commands you will still need to write your math and anything else required to do what you need it to do (you can see why I just recommend Animation Engine ;-) )

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Avoid Collision

Post by Surbhit29 » Fri Aug 17, 2012 5:41 am

I have gone through the manual of Animation engine but it only says about detecting collision. How to stop collision between two objects. Please send me the link if you have any. Thanks for the reply.

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Avoid Collision

Post by Surbhit29 » Fri Aug 17, 2012 8:40 am

Can you send me the link of that demo by Malte...?

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Avoid Collision

Post by shaosean » Fri Aug 17, 2012 9:18 am

From reading your other posts, you already have it..

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Avoid Collision

Post by Surbhit29 » Wed Aug 22, 2012 7:58 am

I tried to use "is within" operator but it is showing the error "Operators is: right operand of within is not a rectangle near 140"
This my script

Code: Select all

on mouseDown
  grab me
   point "248, 215" is within 140, 108, 356, 322
end mouseDown
Is it ok?

LittleGreyMan
Posts: 49
Joined: Sat Jun 16, 2012 7:57 pm
Location: City of God Lug

Re: Avoid Collision

Post by LittleGreyMan » Wed Aug 22, 2012 8:20 am

Hi,

Sorry to be harsh, but RTFM! :wink: It will require less time then posting here and you will learn a lot!

The Dictionary example for within is:

Code: Select all

"22,33" is within "22,17,150,200"
Do you notice anything?

HTH
Best regards,

Didier

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Avoid Collision

Post by Surbhit29 » Wed Aug 22, 2012 8:42 am

Already tried that. But it gives an error" bad command"

LittleGreyMan
Posts: 49
Joined: Sat Jun 16, 2012 7:57 pm
Location: City of God Lug

Re: Avoid Collision

Post by LittleGreyMan » Wed Aug 22, 2012 8:59 am

Really? Are you sure you *exactly* tried that?

If I type:

Code: Select all

answer ("248, 215" is within "140, 108, 356, 322")
in the message box, LC returns true. I copied and pasted from your post, just added the quotes.

HTH
Best regards,

Didier

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Avoid Collision

Post by Klaus » Wed Aug 22, 2012 1:26 pm

Hi Surbhit29,
Surbhit29 wrote:Already tried that. But it gives an error" bad command"
Because you are using it inside of your "mousedown" handler without any "put" or "get" or "answer" or whatever!
And that does not make any sense and is in fact a "bad command".

Do yourself a favour and check the basics of Livecode with the help of these stacks:
http://www.runrev.com/developers/lesson ... nferences/


Best

Klaus

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Avoid Collision

Post by Surbhit29 » Wed Aug 22, 2012 2:18 pm

Thnx Klaus... :)

Post Reply

Return to “Games”