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

Author Topic: Yet another clock thread  (Read 5245 times)

0 Members and 1 Guest are viewing this topic.

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Yet another clock thread
« on: April 13, 2012, 02:16:37 pm »
Hey, I'm using SFML 1.6 on a win 7 machine.

My problem is that my program needs a stopable watch, so I am trying to modify the sf::clock class to include a stopwatch function. The function looks like this.

bool Clock::stopwatch(int ms)
{
        if (GetTime() > stopwatch_start + ms ) {
        stopwatch_start = GetTime();
        return true;}
        else return false;
}
 
GetTime() is just: return static_cast<double>sf::priv::Platform::GetSystemTime();
Anyhow, the problem isn't with the function itself. The problem is the stopwatch_start.
Apparently declaring a extra int/float/double/dword variable in the clock.hpp file causes the Renderwindow function Clear(); to malfunction and give me an access violation reading error on the next line.

The program runs fine(with the exclusion of the stopwatch function) if I remove declaration of the stopwatch_start. (for the reference it is declared as double stopwatch_start; as a private member of clock).

Could anyone post me any tips?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Yet another clock thread
« Reply #1 on: April 13, 2012, 02:24:18 pm »
You can't change SFML's source code without recompiling it.

And is it really necessary to modify SFML? Can't you implement a StopWatch class in your own code?

By the way, the Thor library has such a pausable clock.
Laurent Gomila - SFML developer

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: Yet another clock thread
« Reply #2 on: April 13, 2012, 02:40:44 pm »
Ya, I suppose I'll have to make a stopwatch in my own code :P.
Also when I went to Thors website it said that I had to have C++ TR1, which I do not(I think).

The reason I wanted to use sfmls class instead was simply convenience.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Yet another clock thread
« Reply #3 on: April 13, 2012, 02:48:05 pm »
Quote
Also when I went to Thors website it said that I had to have C++ TR1, which I do not(I think)
Which compiler do you use?
Laurent Gomila - SFML developer

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: Yet another clock thread
« Reply #4 on: April 13, 2012, 02:52:19 pm »
VC++2007

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Yet another clock thread
« Reply #5 on: April 13, 2012, 02:54:56 pm »
This version of VC++ doesn't exist ;D
Laurent Gomila - SFML developer

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: Yet another clock thread
« Reply #6 on: April 13, 2012, 02:55:49 pm »
Dang, meant 2008 ^^

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Yet another clock thread
« Reply #7 on: April 13, 2012, 02:57:27 pm »
VC++ 2008 has TR1, as far as I know.
Laurent Gomila - SFML developer

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: Yet another clock thread
« Reply #8 on: April 13, 2012, 02:58:46 pm »
Ah, nice then I will try to recompile my code with thors clock. Much obliged for your help.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Yet another clock thread
« Reply #9 on: April 13, 2012, 05:34:57 pm »
Bad news:
  • Thor is not compatible to SFML 1.6 (it has never been).
  • For the most recent GitHub version, you need at least Visual Studio 2010.
  • Visual Studio 2008 only supports TR1 in its service pack.
Sorry :-\
But thanks for the hint to update my website! ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Yet another clock thread
« Reply #10 on: April 13, 2012, 07:01:11 pm »
SFML / OS X developer

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: Yet another clock thread
« Reply #11 on: April 14, 2012, 06:50:43 pm »
H: Thanky you!

N: Ah ok, well good to know atleast :)

 

anything