Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Drawing a Circle Based on Time  (Read 1810 times)

0 Members and 1 Guest are viewing this topic.

Lotzi11

  • Newbie
  • *
  • Posts: 2
    • View Profile
Drawing a Circle Based on Time
« on: December 20, 2017, 01:51:28 am »
I want to draw a circle in C++ depending on a specific time passed into the loop. What is a good way to do this?


NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: Drawing a Circle Based on Time
« Reply #2 on: December 20, 2017, 05:54:21 pm »
You didn't explain how the circle would depend on the time. Would the time passed determine when the circle is drawn or the circle's attributes such as size or both?

Lotzi11

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Drawing a Circle Based on Time
« Reply #3 on: December 21, 2017, 03:13:14 am »
Sorry, I did a terrible job describing my issue.

I want to draw an outline of a circle around my mouse cursor whenever the player reloads. My idea is to draw the circle in a specific amount of time depending on the gun. So if a guns reload speed is 6 seconds, then the circle should be fully drawn in 6 seconds. This would mean that I would like to drawn some number of points in order to achieve 360 degrees in 6 seconds. Does anyone know of a way to solve this problem.

Also, I'm new to drawing shapes in SFML and I'm trying to find the best way to draw my circle. What is the best way to draw only the outline of a circle?

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: Drawing a Circle Based on Time
« Reply #4 on: December 21, 2017, 10:01:50 am »
That's tricky.

Don't use CircleShape at all, use sf::Points in VertexArray.

You have to know some trigonometry though (which I don't  :P)

You can find any point on a circle with the equation:

point.x = radius * cos(angle);
point.y = radius * sin(angle);

If you draw 360 points over reload time you have your circle.