Wednesday, June 21, 2017

xna 4.0 - Cutting out smaller rectangles from a larger rectangle


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.






No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...