当前位置: 首页>>代码示例>>Java>>正文


Java Polygon.addPoint方法代码示例

本文整理汇总了Java中org.newdawn.slick.geom.Polygon.addPoint方法的典型用法代码示例。如果您正苦于以下问题:Java Polygon.addPoint方法的具体用法?Java Polygon.addPoint怎么用?Java Polygon.addPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.newdawn.slick.geom.Polygon的用法示例。


在下文中一共展示了Polygon.addPoint方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
/**
 * @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);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:23,代码来源:GradientTest.java

示例2: init

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
/**
 * @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);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:20,代码来源:GradientImageTest.java

示例3: init

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
/**
 * @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);
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:28,代码来源:GraphicsTest.java

示例4: drawSolidPolygon

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
/**
 * @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);
}
 
开发者ID:Kairus101,项目名称:soccerRobots,代码行数:24,代码来源:Slick2dDebugDraw.java

示例5: processPoly

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:44,代码来源:LineProcessor.java

示例6: generateSpace

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
/**
 * 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;
		}
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:43,代码来源:GeomUtilTileTest.java

示例7: init

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:32,代码来源:GeomUtilTest.java

示例8: init

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
/**
 * @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);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:14,代码来源:CurveTest.java

示例9: init

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
/**
 * @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);
	
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:14,代码来源:PolygonTest.java

示例10: createPoly

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
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);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:16,代码来源:ShapeTest.java

示例11: renderShadows

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
private void renderShadows(Graphics g) {
	ArrayList<Vector2f> points = new ArrayList<>();

	ArrayList<Shape> shapes = new ArrayList<>(map.getCollisionShapes());
	shapes.add(new Rectangle(0, 0, background.getWidth(), background.getHeight()));

	for (Shape s : shapes) {
		float[] shapePoints = s.getPoints();

		for (int i = 0; i < shapePoints.length; i += 2) {
			Vector2f poi = new Vector2f(shapePoints[i], shapePoints[i + 1]);
			Vector2f[] cPoints = getCollisionPoints(g, poi);

			points.addAll(Arrays.asList(cPoints));
		}
	}

	ShadowPointComparator spComparator = new ShadowPointComparator(thePlayer.getCenter());

	points.sort(spComparator);

	points.add(points.get(0));

	for (int i = 0; i < points.size() - 1; i++) {
		Polygon p = new Polygon();
		p.addPoint(points.get(i).x, points.get(i).y);
		p.addPoint(points.get(i + 1).x, points.get(i + 1).y);
		p.addPoint(thePlayer.getCenter().x, thePlayer.getCenter().y);

		g.fill(p);
	}
}
 
开发者ID:JavaJumperStudios,项目名称:Saboteur,代码行数:33,代码来源:SaboteurGame.java

示例12: getPolygon

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
public static Polygon getPolygon(){
  Polygon shipPoly = new Polygon();

  shipPoly.addPoint(4, 121);
  shipPoly.addPoint(35, 120);
  shipPoly.addPoint(38, 113);
  shipPoly.addPoint(28, 89);
  shipPoly.addPoint(28, 72);
  shipPoly.addPoint(66, 20);
  shipPoly.addPoint(104, 20);
  shipPoly.addPoint(80, 69);
  shipPoly.addPoint(81, 97);
  shipPoly.addPoint(77, 114);
  shipPoly.addPoint(106, 134);
  shipPoly.addPoint(118, 121);
  shipPoly.addPoint(130, 118);
  shipPoly.addPoint(162, 141);
  shipPoly.addPoint(168, 144);
  shipPoly.addPoint(170, 191);
  shipPoly.addPoint(161, 201);
  shipPoly.addPoint(127, 220);
  shipPoly.addPoint(106, 207);
  shipPoly.addPoint(77, 236);
  shipPoly.addPoint(85, 254);
  shipPoly.addPoint(81, 267);
  shipPoly.addPoint(104, 318);
  shipPoly.addPoint(74, 318);
  shipPoly.addPoint(38, 277);
  shipPoly.addPoint(31, 268);
  shipPoly.addPoint(32, 239);
  shipPoly.addPoint(44, 232);
  shipPoly.addPoint(36, 220);
  shipPoly.addPoint(5, 220);

  return shipPoly;
}
 
开发者ID:Hettomei,项目名称:SpaceInvaderSlick,代码行数:37,代码来源:AnimShip.java

示例13: processPoly

import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
/**
 * 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;
	
	ArrayList pts = new ArrayList();
	boolean moved = false;
	boolean closed = false;
	
	while (tokens.hasMoreTokens()) {
		String nextToken = tokens.nextToken();
		if (nextToken.equals("L")) {
			continue;
		}
		if (nextToken.equals("z")) {
			closed = true;
			break;
		}
		if (nextToken.equals("M")) {
			if (!moved) {
				moved = true;
				continue;
			}
			
			return 0;
		}
		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);
		}
	}
	
	poly.setClosed(closed);
	return count;
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:55,代码来源:PolygonProcessor.java


注:本文中的org.newdawn.slick.geom.Polygon.addPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。