Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am working on puzzle app in which i need to snap irregular shapes as they come in contact of one another as i am new to game development so i dont have any idea how to achieve this functionality in my app.Any suggestion would be highly appreciated.

share|improve this question
add comment

1 Answer

It's true that each image has an irregular shape, but you don't need to snap that shape. It also does have a bounding box, and you know where that bounding box should be in the solved puzzle. Note that those bounding boxes can collide but it doesn't matter at all! so you just need to check if the bounding box almost as it's rightful position, and if it is, you just need to move it to it's exact position and lock it.

share|improve this answer
1  
Actually you don't need to use the bounding boxes, it's simpler to just use the position of the image, but yeah just store a list of where each piece is positioned relative to it's neighbor and snap to those target positions. –  jhocking May 6 '13 at 12:56
    
Thanx a lot Gajoo.I got your idea .Could you provide some relevent code for the same. –  Niks May 6 '13 at 12:58
1  
@jhocking If rotation is allowed, you'll need more than just the one position, you'd need two corners or position and rotation. Otherwise, yes, just the position will work. –  Byte56 May 6 '13 at 13:00
    
Actually the pieces are of different shapes such as triangles, parallelogram etc.Now i need to snap these pieces to crete a meaningful shape. –  Niks May 6 '13 at 13:02
    
Yeah rotation is also possible. Pieces can rotate and can flip as well. –  Niks May 6 '13 at 13:04
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.