Instead of rectangles, I would use a different approach. Rather than checking for overlapping rects, I would use the starting loc and compare against the distance between the loc of the dropped sprite to the loc of the underlying sprite. Then I would use the work of Mr. Pythagoras many years ago to see how far away these points are.

For example, if you had a starting point of (10, 10), and a user drops a piece at (13, 14) (point chosen for easy math), then using the Pythagorean theorem, you know that the drop is 5 pixels away from the exact location. You have to determine what is an "exectable" about of variance.

I have previously done a similar puzzle, and there is a trick you can use. You do not need two sprites. If you start by laying out the puzzle in the score in the final solved state, then you know where the solving point is. Then you can remember the final point in a behavior, and set a new location at random. For example:

property pStartingLoc
property spriteNum

on beginSprite me
  pStartingLoc = sprite(spriteNum).loc
newLoc = random((the stage).right, (the stage).left) -- or however you choose locations.
  sprite(spriteNum).loc = newLoc
end

Then do your dragging and dropping here, and on mouseUp (and mouseUpOutside) do your distance check.

Hope this helps,

Irv

At 7:23 PM +0200 7/25/05, Michael Nadel wrote:
I'm making a puzzle game where I have each sprite in the score twice. Once (underneath) the sprite's blend = 0 and above it (the sprite that you drag's) blend = 100. When the sprite you are dragging intersects the invisible sprite underneath, the invisible sprite becomes visible and the drag sprite is thrown off the stage.

My question is, the "intersect" function is too vague and too easy. I want that the user should be almost exactly on top of the invisible sprite in order for the puzzle piece to become visible. Is there another way to do this that would test if the user is approximately almost exactly within the rect of the invisible sprite?? (not "exactly", but "approximately exactly?")

Thanks for any help!

Michael Nadel
MediArt.Corp
"Creativity is more powerful than knowledge" -- Albert Einstein
***********************************************************************
Tel: (972-2) 5807-454
Email: [EMAIL PROTECTED]
Web: http://www.intelligineering.com/mediart/home.htm

[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email lingo-l@penworks.com (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]


--

Multimedia Wrangler.
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
lingo-l@penworks.com  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to