How can I make multiple shapes using a class that has functions?
Here is my code for the class:
class baseAttributes
{
public:
//baseAttributes();
//~baseAttributes();
int getRadius;
sf::CircleShape baseOutline(int x, int y, int r)
{
sf::CircleShape baseShape(r, 100);
baseShape.setFillColor(sf::Color(0, 0, 255, 15));
baseShape.setOutlineThickness(2);
baseShape.setOutlineColor(sf::Color(28, 87, 174));
baseShape.setRadius(r);
baseShape.setPosition(x - r, y - r);
getRadius = baseShape.getRadius();
return baseShape;
}
sf::CircleShape baseShape(int x, int y, int r)
{
sf::CircleShape base;
base.setFillColor(sf::Color(0, 200, 0));
base.setRadius(r);
base.setPosition(x - r, y - r);
return base;
}
};
and my main
int main()
{
sf::ContextSettings settings;
int width = 1280;
int height = 720;
settings.antialiasingLevel = 8;
sf::RenderWindow window(sf::VideoMode(width, height), "SFML works!", sf::Style::Default, settings);
//window.setMouseCursorVisible(false);
sf::View view;
view.reset(sf::FloatRect(0, 0, width, height));
view.setCenter(0, 0);
view.setViewport(sf::FloatRect(0.f, 0.f, 1.f, 1.f));
window.setView(view);
int mouseX;
int mouseY;
baseAttributes p;
sf::CircleShape player(40, 6);
player.setFillColor(sf::Color::Magenta);
//Loads font
sf::Font OCRAStd;
if(!OCRAStd.loadFromFile("OCRAStd.otf"));
{
std::cout << "Font loaded" << std::endl;
}
sf::Text font;
font.setFont(OCRAStd);
while (window.isOpen())
{
sf::Event event;
//window.setFramerateLimit(120);
while (window.pollEvent(event))
{
switch(event.type)
{
case sf::Event::Closed:
window.close();
break;
//case sf::Keyboard::Escape:
// window.close();
// break;
}
}
//if(event.type == sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
//{
// window.close();
//}
if(event.type == sf::Event::MouseMoved)
{
mouseX = event.mouseMove.x;
mouseY = event.mouseMove.y;
}
player.setPosition(mouseX - width/2, mouseY - height/2);
//int px(0), py(0);
window.clear(sf::Color::Black);
window.draw(p.baseOutline(0, 0, 200));
//Using Pythagorean theorem to display a shape when mouse is in circle
if(pow(player.getPosition().x, 2) + pow(player.getPosition().y, 2) <= pow(p.getRadius, 2))
{
window.draw(player);
}
window.display();
}
return 0;
}
I don't know "baseAttributes p" can have multiple instances, and I don't know what to do to make multiple shapes using that class