Art 412 Stephen Wilson Demo of a puzzle game The user is challenged to drag several items The union function checks if one sprite is within another Union of 2 rects gives the smallest rect that will enclose them both If the union function returns the big rectangle (ho) then that means the little rectangle is inside of it this example checks if all the sprites (2,3,4) have been dragged inside of sprite 1 You need to make sprites (2,3,4) moveable in the property inspector It uses a subroutine called 'checktoys' Toyflag will be = 3 only when all of them are dragged inside People can cheat but it shows the principle on exitFrame me checktoys end on checktoys toyflag = 0 a= sprite(2).rect b= sprite(3).rect c= sprite(4).rect box=sprite(1).rect if union (a, ho) = box then toyflag = toyflag+1 if union (b, ho) = box then toyflag = toyflag+1 if union (c, ho) = box then toyflag = toyflag+1 if toyflag = 3 then beep 6 -- put whatever you want here for winning end if end ============= this one works similar except that each sprite has to be dragged to its proper place it is like a jigsaw puzzle each sprite has another sprite it must link with on exitFrame me checktoys end on checktoys toyflag = 0 a= sprite(2).rect b= sprite(3).rect c= sprite(4).rect abox=sprite(7).rect bbox= sprite(8).rect cbox= sprite(9).rect if union (a, abox) = abox then toyflag = toyflag+1 if union (b, bbox) = bbox then toyflag = toyflag+1 if union (c, cbox) = cbox then toyflag = toyflag+1 if toyflag = 3 then beep 6 -- put whatever you want here for winning end if end