package org.newdawn.slick.tests; import java.util.ArrayList; import java.util.HashSet; import org.newdawn.slick.AppGameContainer; import org.newdawn.slick.BasicGame; import org.newdawn.slick.Color; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.SlickException; import org.newdawn.slick.geom.Circle; import org.newdawn.slick.geom.GeomUtil; import org.newdawn.slick.geom.GeomUtilListener; import org.newdawn.slick.geom.Polygon; import org.newdawn.slick.geom.Shape; import org.newdawn.slick.geom.Vector2f; /** * A test to try shape building from multiple tiles * * @author Kevin Glass */ public class GeomUtilTileTest extends BasicGame implements GeomUtilListener { /** The shape we're cutting out of */ private Shape source; /** The shape we're cutting */ private Shape cut; /** The resulting shape */ private Shape[] result; /** The util under test */ private GeomUtil util = new GeomUtil(); /** The original list of shapes */ private ArrayList original = new ArrayList(); /** The original list of shapes */ private ArrayList combined = new ArrayList(); /** The list of intersection points */ private ArrayList intersections = new ArrayList(); /** The list of used points */ private ArrayList used = new ArrayList(); /** The quad space of shapes that need to be checked against each other */ private ArrayList[][] quadSpace; /** The shapes present in each quad space - used to optimize generation */ private Shape[][] quadSpaceShapes; /** * Create a simple test */ public GeomUtilTileTest() { super("GeomUtilTileTest"); } /** * So this is going to generate a quad space that holds that segments the * shapes into quads across the map. This makes it tunable and limits the number * of comparisons that need to be done for each shape * * @param shapes The shapes to be segments * @param minx The minimum x value of the map * @param miny The mimimum y value of the map * @param maxx The maximum x value of the map * @param maxy The maximum y value of the map * @param segments The number of segments to split the map into */ private void generateSpace(ArrayList shapes, float minx, float miny, float maxx, float maxy, int segments) { quadSpace = new ArrayList[segments][segments]; quadSpaceShapes = new Shape[segments][segments]; float dx = (maxx - minx) / segments; float dy = (maxy - miny) / segments; for (int x=0;x