Do I have to program my own RectsOverlap function or am I missing the new equivalent?
RectsOverlap
BlitzMax Forums/BlitzMax Beginners Area/RectsOverlap Or you could do..
Function OverLap (x0,y0,x1,y1,wid,hig)
Function OverLap (x0,y0,x1,y1,wid,hig)
Thanks James, Birdie is closest to retaining compatability with the old one so that wins it for me.
I'm coding my own exact replacement for the old syntax.
Shagwana did a nice n fast one. I've adapted it to use in a Bmax TRectangle type.
This one is fast, but might give weird results with negative coordinates.
Type TRectangle Method Intersect:Int( rect:TRectangle ) '// Thanks to Shagwana for this return ( ( ( ( (rect.X + rect.W) - X) ^ ( rect.X - (X + W) ) ) And ( ( rect.Y - (Y + H) ) ^ ( (rect.Y + rect.H) - Y ) ) ) And $80000000 ) End Method End Type
This one is fast, but might give weird results with negative coordinates.
I don't know how to use that last one?
With the OOP version, where would I put the code?
Or change the "Method" into "Function" and just call:
TRectangle.Intersect
TRectangle.Intersect
Is it possible somebody could post a short program? I'm confused.
Thanks,
Thanks,
I don't think you want to place it in the type just because you can. I really don't see why you would want a function like this inside an extended type. If you extend TRectangle with MyTRectangle then one or both of your types need to be a MyTRectangle. If I defined TRectangle myself I might put it in but in this case, I would just do
function Intersect:Int( r1:TRectangle, r2:TRectangle )
'// Thanks to Shagwana for this
return ( ( ( ( (r2.X + r2.W) - r1.X) ^ ( r2.X - (r1.X + r1.W) ) ) And ( ( r2.Y - (r1.Y + r1.H) ) ^ ( (r2.Y + r2.H) - r1.Y ) ) ) And $80000000 )
End Method
this function just compares base information that's why I wouldn't put it in an extended type.
function Intersect:Int( r1:TRectangle, r2:TRectangle )
'// Thanks to Shagwana for this
return ( ( ( ( (r2.X + r2.W) - r1.X) ^ ( r2.X - (r1.X + r1.W) ) ) And ( ( r2.Y - (r1.Y + r1.H) ) ^ ( (r2.Y + r2.H) - r1.Y ) ) ) And $80000000 )
End Method
this function just compares base information that's why I wouldn't put it in an extended type.
Yep thats one of my babys!.
Original work is here. It does work but only if you obey certain rules when working with it (see link).
Original work is here. It does work but only if you obey certain rules when working with it (see link).
just thought i should point out to anyone using defiance's version up there, that you should have ~ instead of ^ as xor and you should be using & instead of "and"