bool CollidePixel(int obj1, int obj2) { int s1 = GetObjectSprite(obj1); int s2 = GetObjectSprite(obj2); int x1, y1; GetObjectLocation(obj1, &x1, &y1); int x2, y2; GetObjectLocation(obj2, &x2, &y2); return CollideSprite(s1, s2, x2-x1, y2-y1); }
pascal OSErr FSMakeFSSpecCompat(short vRefNum, long dirID, ConstStr255Param fileName, FSSpec *spec) { OSErr result; #if !__MACOSSEVENORLATER if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() ) { Boolean isDirectory; result = GetObjectLocation(vRefNum, dirID, fileName, &(spec->vRefNum), &(spec->parID), spec->name, &isDirectory); } else #endif /* !__MACOSSEVENORLATER */ { /* Let the file system create the FSSpec if it can since it does the job */ /* much more efficiently than I can. */ result = FSMakeFSSpec(vRefNum, dirID, fileName, spec); /* Fix a bug in Macintosh PC Exchange's MakeFSSpec code where 0 is */ /* returned in the parID field when making an FSSpec to the volume's */ /* root directory by passing a full pathname in MakeFSSpec's */ /* fileName parameter. Fixed in Mac OS 8.1 */ if ( (result == noErr) && (spec->parID == 0) ) spec->parID = fsRtParID; } return ( result ); }
// Does Object1 @ (nX1,nY1) intersect with Object2 @ (nX2, nY2) bool CollideBBox(int obj1, int obj2) { int x1, y1; int width1, height1; GetObjectLocation(obj1, &x1, &y1); GetObjectSize(obj1, &width1, &height1); int x2, y2; int width2, height2; GetObjectLocation(obj2, &x2, &y2); GetObjectSize(obj2, &width2, &height2); if (x1 + width1 < x2) return false; if (x2 + width2 < x1) return false; if (y1 + height1 < y2) return false; if (y2 + height2 < y1) return false; return true; }