Collision detection

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
dgm
Posts: 8
Joined: Sat Nov 11, 2006 5:13 am

Collision detection

Post by dgm » Mon Dec 18, 2006 7:25 pm

Hi,

I want to make a simple game like pong and would like to know how I can detect that the moving image has hit the wall ( an object or edge of the card) so it can bounce back. I have looked without success in the documentation.

Thanks,

Dennis

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Dec 18, 2006 9:41 pm

Hi Dennis,

You could check whether the topleft, topright, bottomleft or bottomright of your moving object is within the object that depicts the wall. You could also check out Animation Engine.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Post by malte » Tue Dec 19, 2006 8:39 am

Hi Dennis,

to check ball / paddle and ball / brick collisions the built in intersect() function should be what you need.

if intersect(button "ball",button "paddle") then
-- collision occured
end if

If you need more sophisticated collision detection and/or asynchronous movement, AnimationEngine can help you.

All the best,

Malte

marielle
Livecode Opensource Backer
Livecode Opensource Backer

Post by marielle » Tue Dec 19, 2006 9:44 am

You could also give a try to the free library that Jock made available:

Forum Post::Announcement::image collision library

dgm
Posts: 8
Joined: Sat Nov 11, 2006 5:13 am

collision detection

Post by dgm » Wed Dec 20, 2006 5:35 am

Thanks guys, this is just what I was looking for.

Dennis

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”