From b81cf7c03bad4fb8ef859b6921c94b472131029d Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sat, 29 Jan 2011 20:18:17 +0100 Subject: Renamed time to timer to avoid conflict. --- time.cpp | 41 ----------------------------------------- time.h | 34 ---------------------------------- timer.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ timer.h | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 75 deletions(-) delete mode 100644 time.cpp delete mode 100644 time.h create mode 100644 timer.cpp create mode 100644 timer.h diff --git a/time.cpp b/time.cpp deleted file mode 100644 index fb2137d..0000000 --- a/time.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "time.h" - -Clock::Clock() { - reset(); - running = false; -} - -void Clock::reset() { - base = 0; - clock.Reset(); -} - -void Clock::start() { - running = true; - clock.Reset(); -} - -void Clock::stop() { - running = false; - base += clock.GetElapsedTime(); -} - -float Clock::elapsed() const { - if(running) { - return base + clock.GetElapsedTime(); - } else { - return base; - } -} - -Timer::Timer(const Clock& clock_) : clock(clock_) { - reset(); -} - -void Timer::reset() { - starttime = clock.elapsed(); -} - -float Timer::elapsed() const { - return clock.elapsed() - starttime; -} diff --git a/time.h b/time.h deleted file mode 100644 index e580f6c..0000000 --- a/time.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef TIME_H -#define TIME_H - -#include - -class Clock { - private: - sf::Clock clock; - bool running; - float base; - - public: - Clock(); - - void reset(); - void start(); - void stop(); - - float elapsed() const; -}; - -class Timer { - private: - const Clock& clock; - float starttime; - - public: - Timer(const Clock& clock_); - - void reset(); - float elapsed() const; -}; - -#endif diff --git a/timer.cpp b/timer.cpp new file mode 100644 index 0000000..1285d65 --- /dev/null +++ b/timer.cpp @@ -0,0 +1,41 @@ +#include "timer.h" + +Clock::Clock() { + reset(); + running = false; +} + +void Clock::reset() { + base = 0; + clock.Reset(); +} + +void Clock::start() { + running = true; + clock.Reset(); +} + +void Clock::stop() { + running = false; + base += clock.GetElapsedTime(); +} + +float Clock::elapsed() const { + if(running) { + return base + clock.GetElapsedTime(); + } else { + return base; + } +} + +Timer::Timer(const Clock& clock_) : clock(clock_) { + reset(); +} + +void Timer::reset() { + starttime = clock.elapsed(); +} + +float Timer::elapsed() const { + return clock.elapsed() - starttime; +} diff --git a/timer.h b/timer.h new file mode 100644 index 0000000..e580f6c --- /dev/null +++ b/timer.h @@ -0,0 +1,34 @@ +#ifndef TIME_H +#define TIME_H + +#include + +class Clock { + private: + sf::Clock clock; + bool running; + float base; + + public: + Clock(); + + void reset(); + void start(); + void stop(); + + float elapsed() const; +}; + +class Timer { + private: + const Clock& clock; + float starttime; + + public: + Timer(const Clock& clock_); + + void reset(); + float elapsed() const; +}; + +#endif -- cgit v1.2.3