#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(1280, 720), "This is the title");
class EllipseShape : public sf::Shape
{
public :
explicit EllipseShape(const sf::Vector2f& radius = sf::Vector2f(0, 0)) : m_radius(radius)
{
update();
}
void setRadius(const sf::Vector2f& radius)
{
m_radius = radius;
update();
}
const sf::Vector2f& getRadius() const
{
return m_radius;
}
virtual unsigned int getPointCount() const
{
return 30; // fixed, but could be an attribute of the class if needed
}
virtual sf::Vector2f getPoint(unsigned int index) const
{
static const float pi = 3.141592654f;
float angle = index * 2 * pi / getPointCount() - pi / 2;
float x = std::cos(angle) * m_radius.x;
float y = std::sin(angle) * m_radius.y;
return sf::Vector2f(m_radius.x + x, m_radius.y + y);
}
private :
sf::Vector2f m_radius;
};
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
window.clear();
window.draw(/*What goes here?*/);
window.display();
}
}
return 0;
}
This is the code, mostly just what is on the tutorial.
I mainly think i am just missing window.draw(??)
I tried EllipseShape, shape, then just tried everything else i could think of
You seem to be lacking a basic understanding of how C++ works. There are no variables called "shape" or "EllipseShape" anywhere in this program. There are classes/types called sf::Shape and EllipseShape, but those are classes, not objects.
To solve your immediate problem you simply need to create an actual object:
EllipseShape anActualObjectOfTypeEllipseShape;
...
window.draw(anActualObjectOfTypeEllipseShape);
Like most software libraries, SFML assumes (and has to assume) that you already know the language it's written in. If you weren't aware that classes are not the same thing as objects, you probably need to go read a good book on C++ (https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) before trying to use libraries written in that language.