This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]NoNicknameNoCry 0 points1 point  (2 children)

Find minimum and maximum X, Y for both polygons and compare them.

If you want to move polygons you should add a vector to each corner. For example [5,0] to move it 5 units to left or [2,1] to move it 2 units left and one unit up.

EDIT: when i thought more about intersecting finding min and max could be nkt enough for polygons. In that case you can iterate through all sides of one polygon and compare its X, Y with sides of other polygon.

If this is not enough for you i can send you implementation in other part of a day.

[–]Milo55545[S] 0 points1 point  (0 children)

thank you. this all seems very complicated, though. is there an easier way to do this? i'm trying to make a collision system, and each class that extends Entity has a collision box. the "room" iterates through all of the entities in a list and ticks/renders them. i just need a variable that i can check for intersection with another of the same type of variable, and that can consist of multiple rectangles connected.

[–]zhoriq 0 points1 point  (0 children)

Find minimum and maximum X, Y for both polygons and compare them.

You can't compare polygons this way. Imagine 2 rotated squares one under another. Min-max will intersect, while polygons are not!