Creating drag and drop feature with collision detection, similar to puzzle or tetris

7 views (last 30 days)
I am working on software to create some structure. My idea is to make GUI in MATLAB with draggable items (squares with known sizes) and use them to create this structure, something like tetris or puzzle. Currently I am using imrect function with squares 1x1 and resizable feature switched off. However, the squares can overlap themselves and this is the problem. I have no idea how to avoid overlapping. My first solution was to set area in which squares can be dragged, but if one square is in the middle of the structure I can't use impoly to mask this area, cause it masks only rectangle. Moreover, I should prepare impoly to each square, since despite of that one, there are another squares and should mask dragging area - and this is the second problem.
Have you any ideas how to solve it?

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!