Cutting out smaller rectangles from a larger rectangle

Posted by Mauro Destro on Game Development See other posts from Game Development or by Mauro Destro
Published on 2012-03-29T06:44:40Z Indexed on 2012/03/29 17:43 UTC
Read the original article Hit count: 265

Filed under:

The world is initially a rectangle. The player can move on the world border and then "cut" the world via orthogonal paths (not oblique). When the player reaches the border again I have a list of path segments they just made.

I'm trying to calculate and compare the two areas created by the path cut and select the smaller one to remove it from world.

After the first iteration, the world is no longer a rectangle and player must move on border of this new shape.

How can I do this? Is it possible to have a non rectangular path? How can I move the player character only on path?

EDIT

Here you see an example of what I'm trying to achieve: 5 phases of a rectangle being cut smaller by other rectangles

  1. Initial screen layout.

  2. Character moves inside the world and than reaches the border again.

  3. Segment of the border present in the smaller area is deleted and last path becomes part of the world border.

  4. Character moves again inside the world.

  5. Segments of border present in the smaller area are deleted etc.

© Game Development or respective owner

Related posts about xna-4.0