Collision polygons kind of working

master
GammelJAN 5 years ago
parent ea2f9f7de0
commit 94c91f54c4

@ -65,39 +65,58 @@ public class StaticMath {
Polygon[] collisionPolygons = new Polygon[4];
// first line of polygon
float[] newVertices = wall.getVertices();
float[] newVertices;
// last four coordinates are all incremented by one, so the polygon is 1 width polygon
for(int i = 4; i < 8; i++){
newVertices[i] = newVertices[i-4] + 1;
}
newVertices = new float[8];
newVertices[0] = wall.getVertices()[0];
newVertices[1] = wall.getVertices()[1];
newVertices[2] = wall.getVertices()[2];
newVertices[3] = wall.getVertices()[3];
newVertices[4] = wall.getVertices()[2];
newVertices[5] = wall.getVertices()[3];
newVertices[6] = wall.getVertices()[0];
newVertices[7] = wall.getVertices()[1];
collisionPolygons[0] = new Polygon(newVertices);
// third line of polygon
newVertices = wall.getVertices();
// last four coordinates are all decremented by one, so the polygon is 1 width polygon
for(int i = 4; i < 8; i++){
newVertices[i-4] = newVertices[i] - 1;
}
collisionPolygons[2] = new Polygon(newVertices);
newVertices = new float[8];
newVertices[0] = wall.getVertices()[2];
newVertices[1] = wall.getVertices()[3];
newVertices[2] = wall.getVertices()[4];
newVertices[3] = wall.getVertices()[5];
newVertices[4] = wall.getVertices()[2];
newVertices[5] = wall.getVertices()[3];
newVertices[6] = wall.getVertices()[0];
newVertices[7] = wall.getVertices()[1];
collisionPolygons[1] = new Polygon(newVertices);
// second line of polygon
newVertices = wall.getVertices();
newVertices[0] = newVertices[2];
newVertices[1] = newVertices[3] + 1;
newVertices[6] = newVertices[4];
newVertices[7] = newVertices[5] + 1;
collisionPolygons[1] = new Polygon(newVertices);
newVertices = new float[8];
newVertices[0] = wall.getVertices()[4];
newVertices[1] = wall.getVertices()[5];
newVertices[2] = wall.getVertices()[6];
newVertices[3] = wall.getVertices()[7];
newVertices[4] = wall.getVertices()[2];
newVertices[5] = wall.getVertices()[3];
newVertices[6] = wall.getVertices()[0];
newVertices[7] = wall.getVertices()[1];
collisionPolygons[2] = new Polygon(newVertices);
// fourth line of polygon
newVertices = wall.getVertices();
newVertices[2] = newVertices[0];
newVertices[3] = newVertices[1] - 1;
newVertices[4] = newVertices[6];
newVertices[5] = newVertices[7] - 1;
newVertices = new float[8];
newVertices[0] = wall.getVertices()[6];
newVertices[1] = wall.getVertices()[7];
newVertices[2] = wall.getVertices()[0];
newVertices[3] = wall.getVertices()[1];
newVertices[4] = wall.getVertices()[2];
newVertices[5] = wall.getVertices()[3];
newVertices[6] = wall.getVertices()[0];
newVertices[7] = wall.getVertices()[1];
collisionPolygons[3] = new Polygon(newVertices);

Loading…
Cancel
Save