コード例 #1
0
ファイル: SFMLRenderer.cpp プロジェクト: dexter1986/unli
void SFMLRenderer::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color){

	ConvexShape poligono;
	
	poligono.setPointCount(vertexCount);

	for(int i=0;i<vertexCount;++i){		
		poligono.setPoint(i,Vector2f(vertices[i].x, vertices[i].y));		
	}

	poligono.setFillColor(box2d2SFMLColor(color));
	
	wnd->draw(poligono);

}
コード例 #2
0
ファイル: original.cpp プロジェクト: TCiras/computingIV
void Other::draw(RenderTarget& target, RenderStates states) const {
	ConvexShape rectangle;
  	rectangle.setPointCount(4);
  	rectangle.setPoint(0, A);
	rectangle.setPoint(1, B);
	rectangle.setPoint(2, C);
	rectangle.setPoint(3, D);
	rectangle.setFillColor(Color(55 + (depth*depth), 55 + (depth*depth), 55 + (depth*depth)));
	target.draw(rectangle, states);
	
	if (depth == 1){
		return;
	}
	
	/* Skeliton for two new squares */
	double length = sqrt(pow(A.x - B.x, 2) + pow(A.y - B.y, 2))/2;
	Vector2f upper, right, temp1, temp2, temp3;
	upper.x = (A.x + B.x)/2;
	upper.y = A.y;
	right.x = C.x;
	right.y = (B.x + C.x)/2 + length;
	
	/* Defining upper square */
	temp1.x = upper.x - length;
	temp1.y = upper.y - length;
	temp2.x = upper.x;
	temp2.y = upper.y - length;
	temp3.x = upper.x - length;
	temp3.y = upper.y;
	Other child1(temp1, temp2, upper, temp3, depth - 1);
	target.draw(child1, states);
	
	/* Defining right square */
	temp1.x = right.x + length;
	temp1.y = right.y;
	temp2.x = right.x + length;
	temp2.y = right.y + length;
	temp3.x = right.x;
	temp3.y = right.y + length;
	Other child2(right, temp1, temp2, temp3, depth - 1);
	target.draw(child2, states);
	
	return;
}