Java 类org.newdawn.slick.geom.Polygon 实例源码

项目:trashjam2017    文件:GradientTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    rect = new Rectangle(400,100,200,150);
    round = new RoundedRectangle(150,100,200,150,50);
    round2 = new RoundedRectangle(150,300,200,150,50);
    center = new Rectangle(350,250,100,100);

    poly = new Polygon();
    poly.addPoint(400,350);
    poly.addPoint(550,320);
    poly.addPoint(600,380);
    poly.addPoint(620,450);
    poly.addPoint(500,450);

    gradient = new GradientFill(0,-75,Color.red,0,75,Color.yellow,true);
    gradient2 = new GradientFill(0,-75,Color.blue,0,75,Color.white,true);
    gradient4 = new GradientFill(-50,-40,Color.green,50,40,Color.cyan,true);
}
项目:trashjam2017    文件:GradientImageTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image1 = new Image("testdata/grass.png");
    image2 = new Image("testdata/rocks.png");

    fill = new GradientFill(-64,0,new Color(1,1,1,1f),64,0,new Color(0,0,0,0));
    shape = new Rectangle(336,236,128,128);
    poly = new Polygon();
    poly.addPoint(320,220);
    poly.addPoint(350,200);
    poly.addPoint(450,200);
    poly.addPoint(480,220);
    poly.addPoint(420,400);
    poly.addPoint(400,390);
}
项目:trashjam2017    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    shapes = new ArrayList();
    rect = new Rectangle(10, 10, 100, 80);
    shapes.add(rect);
    roundRect = new RoundedRectangle(150, 10, 60, 80, 20);
    shapes.add(roundRect);
    ellipse = new Ellipse(350, 40, 50, 30);
    shapes.add(ellipse);
    circle = new Circle(470, 60, 50);
    shapes.add(circle);
    polygon = new Polygon(new float[]{550, 10, 600, 40, 620, 100, 570, 130});
    shapes.add(polygon);

    keys = new boolean[256];
    lastChar = new char[256];
    createPoly(200,200);
}
项目:trashjam2017    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:Progetto-C    文件:GradientTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    rect = new Rectangle(400,100,200,150);
    round = new RoundedRectangle(150,100,200,150,50);
    round2 = new RoundedRectangle(150,300,200,150,50);
    center = new Rectangle(350,250,100,100);

    poly = new Polygon();
    poly.addPoint(400,350);
    poly.addPoint(550,320);
    poly.addPoint(600,380);
    poly.addPoint(620,450);
    poly.addPoint(500,450);

    gradient = new GradientFill(0,-75,Color.red,0,75,Color.yellow,true);
    gradient2 = new GradientFill(0,-75,Color.blue,0,75,Color.white,true);
    gradient4 = new GradientFill(-50,-40,Color.green,50,40,Color.cyan,true);
}
项目:Progetto-C    文件:GradientImageTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image1 = new Image("testdata/grass.png");
    image2 = new Image("testdata/rocks.png");

    fill = new GradientFill(-64,0,new Color(1,1,1,1f),64,0,new Color(0,0,0,0));
    shape = new Rectangle(336,236,128,128);
    poly = new Polygon();
    poly.addPoint(320,220);
    poly.addPoint(350,200);
    poly.addPoint(450,200);
    poly.addPoint(480,220);
    poly.addPoint(420,400);
    poly.addPoint(400,390);
}
项目:Progetto-C    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    shapes = new ArrayList();
    rect = new Rectangle(10, 10, 100, 80);
    shapes.add(rect);
    roundRect = new RoundedRectangle(150, 10, 60, 80, 20);
    shapes.add(roundRect);
    ellipse = new Ellipse(350, 40, 50, 30);
    shapes.add(ellipse);
    circle = new Circle(470, 60, 50);
    shapes.add(circle);
    polygon = new Polygon(new float[]{550, 10, 600, 40, 620, 100, 570, 130});
    shapes.add(polygon);

    keys = new boolean[256];
    lastChar = new char[256];
    createPoly(200,200);
}
项目:Progetto-C    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:BaseClient    文件:GradientTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    rect = new Rectangle(400,100,200,150);
    round = new RoundedRectangle(150,100,200,150,50);
    round2 = new RoundedRectangle(150,300,200,150,50);
    center = new Rectangle(350,250,100,100);

    poly = new Polygon();
    poly.addPoint(400,350);
    poly.addPoint(550,320);
    poly.addPoint(600,380);
    poly.addPoint(620,450);
    poly.addPoint(500,450);

    gradient = new GradientFill(0,-75,Color.red,0,75,Color.yellow,true);
    gradient2 = new GradientFill(0,-75,Color.blue,0,75,Color.white,true);
    gradient4 = new GradientFill(-50,-40,Color.green,50,40,Color.cyan,true);
}
项目:BaseClient    文件:GradientImageTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image1 = new Image("testdata/grass.png");
    image2 = new Image("testdata/rocks.png");

    fill = new GradientFill(-64,0,new Color(1,1,1,1f),64,0,new Color(0,0,0,0));
    shape = new Rectangle(336,236,128,128);
    poly = new Polygon();
    poly.addPoint(320,220);
    poly.addPoint(350,200);
    poly.addPoint(450,200);
    poly.addPoint(480,220);
    poly.addPoint(420,400);
    poly.addPoint(400,390);
}
项目:BaseClient    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    shapes = new ArrayList();
    rect = new Rectangle(10, 10, 100, 80);
    shapes.add(rect);
    roundRect = new RoundedRectangle(150, 10, 60, 80, 20);
    shapes.add(roundRect);
    ellipse = new Ellipse(350, 40, 50, 30);
    shapes.add(ellipse);
    circle = new Circle(470, 60, 50);
    shapes.add(circle);
    polygon = new Polygon(new float[]{550, 10, 600, 40, 620, 100, 570, 130});
    shapes.add(polygon);

    keys = new boolean[256];
    lastChar = new char[256];
    createPoly(200,200);
}
项目:BaseClient    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:Generic-Zombie-Shooter-Redux    文件:Claymore.java   
public Claymore(Particle p_) {
    super(p_, 0.0);

    this.explosion = AssetManager.getManager().getSound(Claymore.EXP_SOUND);

    float mTheta = theta - (float)(Math.PI / 2);
    float magX1 = (float)(Math.cos(mTheta - (SHRAPNEL_SPREAD / 2)) * EXP_RANGE);
    float magY1 = (float)(Math.sin(mTheta - (SHRAPNEL_SPREAD / 2)) * EXP_RANGE);
    float magX2 = (float)(Math.cos(mTheta + (SHRAPNEL_SPREAD / 2)) * EXP_RANGE);
    float magY2 = (float)(Math.sin(mTheta + (SHRAPNEL_SPREAD / 2)) * EXP_RANGE);
    this.collider = new Polygon(new float[] { position.x, position.y, 
                                              (position.x + magX1), (position.y + magY1), 
                                              (position.x + magX2), (position.y + magY2) 
                                            });

    this.shrapnel = new ArrayList<Projectile>();
    this.exploded = false;
    this.shrapnelCreated = false;
}
项目:sdd-major    文件:CollisionDetector.java   
public static void update(int delta) {
    ArrayList<EntityBase> ingameEntites = IngameState.getInstance().entityManager.getIngameEntities();
    for(EntityBase entityCheck : ingameEntites) {
        if(entityCheck instanceof ICollisionDetection) {
            Polygon p1 = entityCheck.collisionShape;
            for(EntityBase entity : ingameEntites) {
                if(!entity.equals(entityCheck)) {
                    Polygon p2 = entity.collisionShape;
                    double d1 = p1.getBoundingCircleRadius();
                    double d2 = p2.getBoundingCircleRadius();
                    //uses the squared distance because sqrt is extremely expensive
                    double distance = distanceSquaredBetweenPolygon(p1, p2);
                    if(distance <= Math.pow(d1+d2, 2)) {
                        ((ICollisionDetection) entityCheck).onCollision(entity);
                    }
                }
            }
        }
    }
}
项目:awesome-game-store    文件:GameTile.java   
/**
 * Creates a polygon at each step and checks if the user has the mouse over
 * it (using polygon.contains). If it does, set that polygon to
 * "mouseOver = true" which, in turn, will set "highlighted = true".
 * 
 * @param container
 * @param game
 * @param delta
 * @param mouseX
 * @param mouseY
 */
public void update(int delta, int mouseX, int mouseY) {

    // Creates the Polygon to check for the Mouse Over check
    polygon = new Polygon(new float[] { points[0] + xOffset,
            points[1] + yOffset, points[2] + xOffset, points[3] + yOffset,
            points[4] + xOffset, points[5] + yOffset, points[6] + xOffset,
            points[7] + yOffset });

    // Checks if the user has the mouse inside the Polygon (Tile)
    if (polygon.contains((float) mouseX / GameSystem.globalScale,
            (float) mouseY / GameSystem.globalScale)) {
        mouseOver = true;
        highlighted = true;
    } else {
        mouseOver = false;
    }
}
项目:soccerRobots    文件:Slick2dDebugDraw.java   
/**
 * @see org.jbox2d.callbacks.DebugDraw#drawSolidPolygon(org.jbox2d.common.Vec2[], int, org.jbox2d.common.Color3f)
 */
@Override
public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) {

        int[] xInts = xIntsPool.get(vertexCount);
        int[] yInts = yIntsPool.get(vertexCount);
        Polygon p = new Polygon();


        for(int i=0; i<vertexCount; i++){
                getWorldToScreenToOut(vertices[i], temp);
                xInts[i] = (int)temp.x;
                yInts[i] = (int)temp.y;
                p.addPoint(xInts[i], yInts[i]);
        }

        g.setColor(new Color(color.x,color.y,color.z));
        g.fill(p); //Draws shape filled with colour
        g.setColor(Color.white);
        //drawPolygon(vertices, vertexCount, color);
}
项目:GPVM    文件:GradientTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    rect = new Rectangle(400,100,200,150);
    round = new RoundedRectangle(150,100,200,150,50);
    round2 = new RoundedRectangle(150,300,200,150,50);
    center = new Rectangle(350,250,100,100);

    poly = new Polygon();
    poly.addPoint(400,350);
    poly.addPoint(550,320);
    poly.addPoint(600,380);
    poly.addPoint(620,450);
    poly.addPoint(500,450);

    gradient = new GradientFill(0,-75,Color.red,0,75,Color.yellow,true);
    gradient2 = new GradientFill(0,-75,Color.blue,0,75,Color.white,true);
    gradient4 = new GradientFill(-50,-40,Color.green,50,40,Color.cyan,true);
}
项目:GPVM    文件:GradientImageTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image1 = new Image("testdata/grass.png");
    image2 = new Image("testdata/rocks.png");

    fill = new GradientFill(-64,0,new Color(1,1,1,1f),64,0,new Color(0,0,0,0));
    shape = new Rectangle(336,236,128,128);
    poly = new Polygon();
    poly.addPoint(320,220);
    poly.addPoint(350,200);
    poly.addPoint(450,200);
    poly.addPoint(480,220);
    poly.addPoint(420,400);
    poly.addPoint(400,390);
}
项目:GPVM    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    shapes = new ArrayList();
    rect = new Rectangle(10, 10, 100, 80);
    shapes.add(rect);
    roundRect = new RoundedRectangle(150, 10, 60, 80, 20);
    shapes.add(roundRect);
    ellipse = new Ellipse(350, 40, 50, 30);
    shapes.add(ellipse);
    circle = new Circle(470, 60, 50);
    shapes.add(circle);
    polygon = new Polygon(new float[]{550, 10, 600, 40, 620, 100, 570, 130});
    shapes.add(polygon);

    keys = new boolean[256];
    lastChar = new char[256];
    createPoly(200,200);
}
项目:GPVM    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:SpaceStationAlpha    文件:GradientTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    rect = new Rectangle(400,100,200,150);
    round = new RoundedRectangle(150,100,200,150,50);
    round2 = new RoundedRectangle(150,300,200,150,50);
    center = new Rectangle(350,250,100,100);

    poly = new Polygon();
    poly.addPoint(400,350);
    poly.addPoint(550,320);
    poly.addPoint(600,380);
    poly.addPoint(620,450);
    poly.addPoint(500,450);

    gradient = new GradientFill(0,-75,Color.red,0,75,Color.yellow,true);
    gradient2 = new GradientFill(0,-75,Color.blue,0,75,Color.white,true);
    gradient4 = new GradientFill(-50,-40,Color.green,50,40,Color.cyan,true);
}
项目:SpaceStationAlpha    文件:GradientImageTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image1 = new Image("testdata/grass.png");
    image2 = new Image("testdata/rocks.png");

    fill = new GradientFill(-64,0,new Color(1,1,1,1f),64,0,new Color(0,0,0,0));
    shape = new Rectangle(336,236,128,128);
    poly = new Polygon();
    poly.addPoint(320,220);
    poly.addPoint(350,200);
    poly.addPoint(450,200);
    poly.addPoint(480,220);
    poly.addPoint(420,400);
    poly.addPoint(400,390);
}
项目:SpaceStationAlpha    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    shapes = new ArrayList();
    rect = new Rectangle(10, 10, 100, 80);
    shapes.add(rect);
    roundRect = new RoundedRectangle(150, 10, 60, 80, 20);
    shapes.add(roundRect);
    ellipse = new Ellipse(350, 40, 50, 30);
    shapes.add(ellipse);
    circle = new Circle(470, 60, 50);
    shapes.add(circle);
    polygon = new Polygon(new float[]{550, 10, 600, 40, 620, 100, 570, 130});
    shapes.add(polygon);

    keys = new boolean[256];
    lastChar = new char[256];
    createPoly(200,200);
}
项目:SpaceStationAlpha    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:cretion    文件:GradientTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    rect = new Rectangle(400,100,200,150);
    round = new RoundedRectangle(150,100,200,150,50);
    round2 = new RoundedRectangle(150,300,200,150,50);
    center = new Rectangle(350,250,100,100);

    poly = new Polygon();
    poly.addPoint(400,350);
    poly.addPoint(550,320);
    poly.addPoint(600,380);
    poly.addPoint(620,450);
    poly.addPoint(500,450);

    gradient = new GradientFill(0,-75,Color.red,0,75,Color.yellow,true);
    gradient2 = new GradientFill(0,-75,Color.blue,0,75,Color.white,true);
    gradient4 = new GradientFill(-50,-40,Color.green,50,40,Color.cyan,true);
}
项目:cretion    文件:GradientImageTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image1 = new Image("testdata/grass.png");
    image2 = new Image("testdata/rocks.png");

    fill = new GradientFill(-64,0,new Color(1,1,1,1f),64,0,new Color(0,0,0,0));
    shape = new Rectangle(336,236,128,128);
    poly = new Polygon();
    poly.addPoint(320,220);
    poly.addPoint(350,200);
    poly.addPoint(450,200);
    poly.addPoint(480,220);
    poly.addPoint(420,400);
    poly.addPoint(400,390);
}
项目:cretion    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    shapes = new ArrayList();
    rect = new Rectangle(10, 10, 100, 80);
    shapes.add(rect);
    roundRect = new RoundedRectangle(150, 10, 60, 80, 20);
    shapes.add(roundRect);
    ellipse = new Ellipse(350, 40, 50, 30);
    shapes.add(ellipse);
    circle = new Circle(470, 60, 50);
    shapes.add(circle);
    polygon = new Polygon(new float[]{550, 10, 600, 40, 620, 100, 570, 130});
    shapes.add(polygon);

    keys = new boolean[256];
    lastChar = new char[256];
    createPoly(200,200);
}
项目:cretion    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:SpaceInvaderSlick    文件:Ship.java   
public Ship(ShipFires fires) {

    this.speed = 0.5f;
    this.fires = fires;
    this.size = 0.4f;

    Transform t = Transform.createScaleTransform(size, size);
    this.shipPoly = AnimShip.getPolygon();
    this.shipPoly = (Polygon) shipPoly.transform(t);

    this.shipRec = new Rectangle(0, 0, 170, 343);
    Shape p = shipRec.transform(t);
    this.shipRec = new Rectangle(p.getX(), p.getY(), p.getWidth(), p.getHeight());
    this.shipPoly.setCenterX(shipRec.getCenterX());
    this.shipPoly.setCenterY(shipRec.getCenterY());

    this.anim_ship = new AnimShip();
  }
项目:slick2d-maven    文件:GradientTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    rect = new Rectangle(400,100,200,150);
    round = new RoundedRectangle(150,100,200,150,50);
    round2 = new RoundedRectangle(150,300,200,150,50);
    center = new Rectangle(350,250,100,100);

    poly = new Polygon();
    poly.addPoint(400,350);
    poly.addPoint(550,320);
    poly.addPoint(600,380);
    poly.addPoint(620,450);
    poly.addPoint(500,450);

    gradient = new GradientFill(0,-75,Color.red,0,75,Color.yellow,true);
    gradient2 = new GradientFill(0,-75,Color.blue,0,75,Color.white,true);
    gradient4 = new GradientFill(-50,-40,Color.green,50,40,Color.cyan,true);
}
项目:slick2d-maven    文件:GradientImageTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image1 = new Image("testdata/grass.png");
    image2 = new Image("testdata/rocks.png");

    fill = new GradientFill(-64,0,new Color(1,1,1,1f),64,0,new Color(0,0,0,0));
    shape = new Rectangle(336,236,128,128);
    poly = new Polygon();
    poly.addPoint(320,220);
    poly.addPoint(350,200);
    poly.addPoint(450,200);
    poly.addPoint(480,220);
    poly.addPoint(420,400);
    poly.addPoint(400,390);
}
项目:slick2d-maven    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    shapes = new ArrayList();
    rect = new Rectangle(10, 10, 100, 80);
    shapes.add(rect);
    roundRect = new RoundedRectangle(150, 10, 60, 80, 20);
    shapes.add(roundRect);
    ellipse = new Ellipse(350, 40, 50, 30);
    shapes.add(ellipse);
    circle = new Circle(470, 60, 50);
    shapes.add(circle);
    polygon = new Polygon(new float[]{550, 10, 600, 40, 620, 100, 570, 130});
    shapes.add(polygon);

    keys = new boolean[256];
    lastChar = new char[256];
    createPoly(200,200);
}
项目:slick2d-maven    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:trashjam2017    文件:LineProcessor.java   
/**
 * Process the points in a polygon definition
 * 
 * @param poly The polygon being built
 * @param element The XML element being read
 * @param tokens The tokens representing the path
 * @return The number of points found
 * @throws ParsingException Indicates an invalid token in the path
 */
private static int processPoly(Polygon poly, Element element, StringTokenizer tokens) throws ParsingException {
    int count = 0;

    while (tokens.hasMoreTokens()) {
        String nextToken = tokens.nextToken();
        if (nextToken.equals("L")) {
            continue;
        }
        if (nextToken.equals("z")) {
            break;
        }
        if (nextToken.equals("M")) {
            continue;
        }
        if (nextToken.equals("C")) {
            return 0;
        }

        String tokenX = nextToken;
        String tokenY = tokens.nextToken();

        try {
            float x = Float.parseFloat(tokenX);
            float y = Float.parseFloat(tokenY);

            poly.addPoint(x,y);
            count++;
        } catch (NumberFormatException e) {
            throw new ParsingException(element.getAttribute("id"), "Invalid token in points list", e);
        }
    }

    return count;
}
项目:trashjam2017    文件:ShapeTest.java   
public void createPoly(float x, float y) {
    int size = 20;
    int change = 10;

    randomShape = new Polygon();
    // generate random polygon
    randomShape.addPoint(0 + (int)(Math.random() * change), 0 + (int)(Math.random() * change));
    randomShape.addPoint(size - (int)(Math.random() * change), 0 + (int)(Math.random() * change));
    randomShape.addPoint(size - (int)(Math.random() * change), size - (int)(Math.random() * change));
    randomShape.addPoint(0 + (int)(Math.random() * change), size - (int)(Math.random() * change));

    // center polygon
    randomShape.setCenterX(x);
    randomShape.setCenterY(y);
}
项目:trashjam2017    文件:GeomUtilTileTest.java   
/**
 * 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<segments;x++) {
        for (int y=0;y<segments;y++) {
            quadSpace[x][y] = new ArrayList();

            // quad for this segment
            Polygon segmentPolygon = new Polygon();
            segmentPolygon.addPoint(minx+(dx*x), miny+(dy*y));
            segmentPolygon.addPoint(minx+(dx*x)+dx, miny+(dy*y));
            segmentPolygon.addPoint(minx+(dx*x)+dx, miny+(dy*y)+dy);
            segmentPolygon.addPoint(minx+(dx*x), miny+(dy*y)+dy);

            for (int i=0;i<shapes.size();i++) {
                Shape shape = (Shape) shapes.get(i);

                if (collides(shape, segmentPolygon)) {
                    quadSpace[x][y].add(shape);
                }
            }

            quadSpaceShapes[x][y] = segmentPolygon;
        }
    }
}
项目:trashjam2017    文件:PolygonTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    poly = new Polygon();
    poly.addPoint(300, 100);
    poly.addPoint(320, 200);
    poly.addPoint(350, 210);
    poly.addPoint(280, 250);
    poly.addPoint(300, 200);
    poly.addPoint(240, 150);

}
项目:trashjam2017    文件:GeomUtilTest.java   
/**
 * Perform the cut
 */
public void init() {
    Polygon source = new Polygon();
    source.addPoint(100,100);
    source.addPoint(150,80);
    source.addPoint(210,120);
    source.addPoint(340,150);
    source.addPoint(150,200);
    source.addPoint(120,250);
    this.source = source;

    circle = new Circle(0,0,50);
    rect = new Rectangle(-100,-40,200,80);
    star = new Polygon();

    float dis = 40;
    for (int i=0;i<360;i+=30) {
        dis = dis == 40 ? 60 : 40;
        double x = (Math.cos(Math.toRadians(i)) * dis);
        double y = (Math.sin(Math.toRadians(i)) * dis);
        star.addPoint((float) x, (float) y);
    }

    this.cut = circle;
    cut.setLocation(203,78);
    xp = (int) cut.getCenterX();
    yp = (int) cut.getCenterY();
    makeBoolean();
}
项目:trashjam2017    文件:CurveTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    container.getGraphics().setBackground(Color.white);

    curve = new Curve(p2,c2,c1,p1);
    poly = new Polygon();
    poly.addPoint(500,200);
    poly.addPoint(600,200);
    poly.addPoint(700,300);
    poly.addPoint(400,300);
}
项目:Progetto-C    文件:LineProcessor.java   
/**
 * Process the points in a polygon definition
 * 
 * @param poly The polygon being built
 * @param element The XML element being read
 * @param tokens The tokens representing the path
 * @return The number of points found
 * @throws ParsingException Indicates an invalid token in the path
 */
private static int processPoly(Polygon poly, Element element, StringTokenizer tokens) throws ParsingException {
    int count = 0;

    while (tokens.hasMoreTokens()) {
        String nextToken = tokens.nextToken();
        if (nextToken.equals("L")) {
            continue;
        }
        if (nextToken.equals("z")) {
            break;
        }
        if (nextToken.equals("M")) {
            continue;
        }
        if (nextToken.equals("C")) {
            return 0;
        }

        String tokenX = nextToken;
        String tokenY = tokens.nextToken();

        try {
            float x = Float.parseFloat(tokenX);
            float y = Float.parseFloat(tokenY);

            poly.addPoint(x,y);
            count++;
        } catch (NumberFormatException e) {
            throw new ParsingException(element.getAttribute("id"), "Invalid token in points list", e);
        }
    }

    return count;
}