about collision routines.

Malte Brill malte.brill at t-online.de
Fri Mar 19 02:17:57 EST 2004


Hi,

I hope this didn´t come up before. This is from a stack I´d like to show at
EuroRevCon...

if you want a simple circle-circle collision detection you might want to
tray this:

Assuming there are two circle graphics. One called "blue" one called "red"


on checkCollideObject
--Circle-circle Collision Check
  put item 1 of the loc of grc "blue" into x1
  put item 1 of the loc of grc "red" into x2
  put item 2 of the loc of grc "blue" into y1
  put item 2 of the loc of grc "red" into y2
  put distance(x1,y1,x2,y2) into theDistance
  put the width of grc "red"/2+the width of grc "blue"/2 into threshold
  if theDistance<threshold then
     put "kaboom! Method Distance math",theDistance,threshold
     --do your stuff here
   end if
end checkCollideObject




function distance x1,y1,x2,y2
  put x1-x2 into compareX
  put y1-y2 into compareY
  put round(sqrt (compareX^2+compareY^2)) into theDistance
  return theDistance
end distance

Best,

Malte



More information about the use-livecode mailing list