Hey guys, I'm working on a small project. I'm wanting to create a circle of circles (weird right?
) Anyway I know the trig formulas of using cos and sin for creating the circle, but when doing this I either get just one circle placed at an offset, or I get a continuous circle (I know the reasioning for that) Anyway here is what I have for my code:
#include <SFML/Graphics.hpp>
#include <cmath>
#define PI 3.14159265
int main()
{
// create the window
sf::RenderWindow window(sf::VideoMode(800, 600), "woot");
// run the program as long as the window is open
while (window.isOpen())
{
// check all the window's events that were triggered since the last iteration of the loop
sf::Event event;
while (window.pollEvent(event))
{
// "close requested" event: we close the window
if (event.type == sf::Event::Closed)
window.close();
}
// clear the window with black color
window.clear();
sf::CircleShape shape(10.f);
shape.setFillColor(sf::Color::Green);
shape.setOrigin(shape.getLocalBounds().width/2,
shape.getLocalBounds().height/2);
shape.setPosition(window.getSize().x/2, window.getSize().y/2);
for(int i = 0; i < 360; i++)
{
shape.move(cos(i*PI/180), sin(i*PI/180));
window.draw(shape);
}
// end the current frame
window.display();
}
}
This draws the continuous circle. If I want a circle placed every 20 degrees or so I should be able to change the i to increase by 20 each time or so I thought. Attached is an example of what I'm wanting to draw. Anyway, does anyone have any advice? I'd really appreciate it! Thanks!