Added SetPointsCount in sf::CircleShape

This commit is contained in:
Laurent Gomila 2011-12-10 15:22:21 +01:00
parent 048abbf46f
commit c33fa1d290
2 changed files with 41 additions and 7 deletions

View file

@ -32,9 +32,11 @@
namespace sf
{
////////////////////////////////////////////////////////////
CircleShape::CircleShape(float radius)
CircleShape::CircleShape(float radius, unsigned int pointsCount) :
myRadius (radius),
myPointsCount(pointsCount)
{
SetRadius(radius);
Update();
}
@ -53,17 +55,26 @@ float CircleShape::GetRadius() const
}
////////////////////////////////////////////////////////////
void CircleShape::SetPointsCount(unsigned int count)
{
myPointsCount = count;
Update();
}
////////////////////////////////////////////////////////////
unsigned int CircleShape::GetPointsCount() const
{
return 30;
return myPointsCount;
}
////////////////////////////////////////////////////////////
Vector2f CircleShape::GetPoint(unsigned int index) const
{
float angle = index * 2 * 3.141592654f / GetPointsCount();
static const float pi = 3.141592654f;
float angle = index * 2 * pi / myPointsCount - pi / 2;
float x = std::cos(angle) * myRadius;
float y = std::sin(angle) * myRadius;