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

Author Topic: sf::Timer class?  (Read 4530 times)

0 Members and 1 Guest are viewing this topic.

MrOnlineCoder

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
sf::Timer class?
« on: March 06, 2017, 07:39:42 pm »
Hello. Very often, in games timers are used. For spell countdown, turn duration, bomb timer, etc... It will be very convinient if SFML would have a timer class. It can be similiar to sf::Clock, but it should go downwards, and it can call a function on end or fire up an event.

Thanks,
MrOnlineCoder


Arcade

  • Full Member
  • ***
  • Posts: 230
    • View Profile
Re: sf::Timer class?
« Reply #1 on: March 07, 2017, 12:23:19 am »
It would probably be fairly easy to just create your own timer class on top of sf::Clock. If you don't want to do it yourself, I think Hapax's Kairos library has one you can use.

MrOnlineCoder

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
Re: sf::Timer class?
« Reply #2 on: March 07, 2017, 11:27:46 am »
I think it is not a rational way to include a library just to use one class. And every feature in this forum can be written by yourself in class  ;)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sf::Timer class?
« Reply #3 on: March 07, 2017, 11:44:29 am »
It's a rational for us. We want to provide low-ish level functionalities with a simple API on to of which you can build whatever you want.
If a feature solely consists of using SFML functions to create a new class, then it's not something we're very inclined to include, because that class can be built by anyone else on top of SFML.
If a feature however requires changes to SFML classes itself or requires the use of OS APIs, then it's something we might think more about including it in SFML, since it can't just be built on top of SFML.

Don't forget that SFML is not an engine nor a framework.

Thor's StopWatch class is quite nice as well, plus when you include Thor, you'll also get access to a lot of other useful clsses.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: sf::Timer class?
« Reply #4 on: March 13, 2017, 01:44:28 pm »
I think Hapax's Kairos library has one you can use.
I think it is not a rational way to include a library just to use one class.
Then don't just use one class. It also has a Timestep class and a clock that can have its speed changed including backwards: Continuum. ;)

And every feature in this forum can be written by yourself in class  ;)
Not true. Try to add native window menus using an SFML window :P
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*