Abstractify some modules completely: timer, keyboard and mouse.

If this commit breaks some project file(s), well ...
I AM RUDE AND I WILL BREAK EVERYTHING, AHAHAHAHAHAHAHHAHAHAHAHA!
This commit is contained in:
rude
2011-10-28 10:47:16 +02:00
parent cd66b01da3
commit 2753c62985
18 changed files with 239 additions and 201 deletions
+25 -60
View File
@@ -25,7 +25,7 @@
#include <SDL.h>
// LOVE
#include <common/Module.h>
#include <timer/Timer.h>
namespace love
{
@@ -37,10 +37,33 @@ namespace sdl
* An SDL timer module. Can keep track of time between certain function
* calls, and provides access to a FPS metric which updates once each second.
**/
class Timer : public Module
class Timer : public love::timer::Timer
{
public:
/**
* Constructor. Initializes the SDL/timer subsystem.
**/
Timer();
/**
* Destructor.
**/
virtual ~Timer();
const char * getName() const;
void step();
void sleep(double seconds);
double getDelta() const;
double getFPS() const;
double getTime() const;
double getMicroTime() const;
private:
// Timing vars for benchmarking.
Uint32 time_init;
// Frame delta vars.
Uint32 currTime;
Uint32 prevTime;
@@ -58,64 +81,6 @@ namespace sdl
// The current timestep.
double dt;
public:
/**
* Constructor. Initializes the SDL/timer subsystem.
**/
Timer();
/**
* Destructor.
**/
~Timer();
/**
* Gets the name of the module.
* @return Always returns "love.timer.sdl".
**/
const char * getName() const;
/**
* Measures the time between this call and the previous call,
* and updates internal values accordinly.
**/
void step();
/**
* Tries to sleep for the specified amount of time. The precision is
* usually 1ms.
* @param seconds The number of seconds to sleep for.
**/
void sleep(double seconds);
/**
* Gets the time between the last two frames, assuming step is called
* each frame.
**/
double getDelta() const;
/**
* Gets the average FPS over the last second. Beucase the value is only updated
* once per second, it does not look erratic when displayed on screen.
* @return The "current" FPS.
**/
double getFPS() const;
/**
* Gets the amount of time since the program started. Only useful for timing
* code or measuring intervals.
* @return The time (in seconds) since the program started.
**/
double getTime() const;
/**
* Gets the amount of time passed since an unspecified time. The time is accurate
* to the microsecond, and is limited to 24 hours.
* @return The time (in seconds)
**/
double getMicroTime() const;
}; // Timer
} // sdl