Yepp seems so :-)
Fredborg: 4205
Shagwana: 4178
What I have not tested thought is if the result is correct.
And fredborg: On my system, & is faster than and ...
Strict Function DetectPointInsideRect(iPointX:Int,iPointY:Int,iXPos1:Int,iYPos1:Int,iXPos2:Int,iYPos2:Int) Return ((((iPointX-iXPos1) ~ (iPointX-iXPos2)) & ((iPointY-iYPos1) ~ (iPointY-iYPos2))) & $80000000) End Function Function PointInRect:Int(x:Int,y:Int,bx:Int,by:Int,bw:Int,bh:Int) Return (x < (bx + bw)) &(y < (by + bh)) &(x > bx) And (y > by) End Function Graphics 640,480,0,0 Local x0:Int = 100 Local y0:Int = 100 Local w0:Int = 200 Local h0:Int = 150 Local x1:Int = x0+w0 Local y1:Int = y0+h0 Local w1:Int = 100 Local h1:Int = 100 Local sx:Int = 1 Local sy:Int = 1 Local x2:Int = Rand(0,639) Local y2:Int = Rand(0,479) Local t1:Int = MilliSecs() For Local i = 1 To 10000000 x2 = Rand(0,639) y2 = Rand(0,479) PointInRect(x2,y2,x0,y0,w0,h0) Next t1 = MilliSecs() - t1 Local t2:Int = MilliSecs() For Local i = 1 To 10000000 x2 = Rand(0,639) y2 = Rand(0,479) DetectPointInsideRect(x2,y2,x0,y0,x1,y1) Next t2 = MilliSecs() - t2 Print "Fredborg: " + t1 Print "Shagwana: " + t2
Fredborg: 4205
Shagwana: 4178
What I have not tested thought is if the result is correct.
And fredborg: On my system, & is faster than and ...