Create polygon from grid (for collisions)

172 views Asked by At

I have two grids, each which are objects with values { x+','+y: ..., x1+','+y: ... }

These grids will always start at 0, 0 and tiles will expand outward. Tiles cannot be connected diagonally. Here is an example:

. . . O .
. O O O .
. . O O .
. . O . .
. O O O O

The center of each of these grids has an X, a Y, and a rotation, both separate from each other. I am trying to figure out when and where they intersect.

I figured I should use a polygon collision library, but I wasn't exactly sure what the most efficient way would be to create polygons from these grids (even non-rotated ones). My server calculates physics every 1/20th of a second. Obviously collisions would only be calculated if the players are near each other, but polygons seemed like a great option because they only need to be recalculated every time the grid changes whereas translating + rotating seems like it would be easier.

So what's the best way to get the polygon from this (without having repeating points on the same side)? Is there a better way to be checking for collisions?

Example of rotated grids: http://i.imgur.com/XVQJvxa.png

0

There are 0 answers