Monkey Forums/Monkey Beginners/Collisions

Grimp(Posted 2014) [#1]
New to the forums here. Was wondering if anybody could point me to info on collisions. Preferably with the module diddy.

Paul - Taiphoz(Posted 2014) [#2]
I'm not sure if diddy has anything built in for collisions, but it's easy enough to quickly do some basic shape detection like distance's or circle to circle or rect to rect etc.

Function emCirclesOverlap:bool(p1x:Float,p1y:Float,p1r:float,p2x:Float,p2y:Float,p2r:float)
	if emDistance(p1x,p1y,p2x,p2y)<=p1r+p2r then
		return True
		return false
End Function

IN terms of pixel perfect collisions, some one just recently posted a module that does it, you can find it in the modules forum, I think for most quick collision checks however something simple like the above will be good enough.

Grimp(Posted 2014) [#3]
Thanks that'll do the job. Just wondering, once you set a variable as Global how can you access it from other classes, for Instance accessing a global list from another class ?

Gerry Quinn(Posted 2014) [#4]
Just make sure the file containing the second class directly or indirectly imports the one containing the first class.

Global theAliens:List< Alien >

import myglobals
For Local alien:Alien = Eachin theAliens
' Do alien stuff