Here's some code that finds whether a particular point is inside a polygon.
Actual routine is not mine, I've found the C code online (
http://www.visibone.com/inpoly/inpoly.c) and translated it into GLB.
It's great for implementing various regions, zones, collision or whatever else into your programs.
Code is pure math, it has nothing to do with graphical polygons (no acceleration) but it supports all kinds of mad polygonal shapes.
SYSTEMPOINTER TRUE
//create polygon
LOCAL poly[]
DIM poly[RND(3)+3][2]
FOR i = 0 TO BOUNDS(poly[], 0) - 1
poly[i][0] = RND(640)
poly[i][1] = RND(480)
NEXT
// main loop
WHILE TRUE
LOCAL mx,my,mba,mbb
MOUSESTATE mx, my, mba, mbb
drawPoly(poly[])
IF inPoly(poly[], mx, my)
PRINT "Inside!",0,0
ENDIF
SHOWSCREEN
WEND
FUNCTION inPoly: poly[], tx, ty
LOCAL newx, newy, oldx, oldy
LOCAL x1, y1, x2, y2
LOCAL inside
LOCAL npoints = BOUNDS(poly[], 0)
IF npoints < 3 THEN RETURN 0
oldx = poly[npoints - 1][0]
oldy = poly[npoints - 1][1]
FOR i = 0 TO npoints - 1
newx = poly[i][0]
newy = poly[i][1]
IF newx > oldx
x1 = oldx
x2 = newx
y1 = oldy
y2 = newy
ELSE
x1 = newx
x2 = oldx
y1 = newy
y2 = oldy
ENDIF
IF ((newx < tx) = (tx <= oldx) AND (ty-y1)*(x2-x1) < (y2-y1)*(tx-x1))
inside = NOT inside
ENDIF
oldx = newx
oldy = newy
NEXT
RETURN inside
ENDFUNCTION
FUNCTION drawPoly: poly[]
LOCAL npoints = BOUNDS(poly[], 0)
FOR i = 0 TO npoints-2
DRAWLINE poly[i][0],poly[i][1], poly[i+1][0],poly[i+1][1], RGB(200,200,200)
NEXT
DRAWLINE poly[-1][0],poly[-1][1], poly[0][0],poly[0][1], RGB(200,200,200)
ENDFUNCTION