Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////**** timer.h ****////
- #ifndef _Timer_H_
- #define _Timer_H_
- #include <oslib/oslib.h>
- class Timer{
- public:
- //Constructor
- Timer(void);
- //Variables
- bool timer_running;
- //Time variables
- clock_t lastTime;
- clock_t pauseTime;
- //Methods
- void start();
- void stop();
- void reset();
- bool running();
- int time();
- };
- #endif
- ////**** timer.c ****////
- #include "timer.h"
- //Constructor
- Timer::Timer(void){
- timer_running = false;
- reset();
- }
- //Methods
- void Timer::start(){
- if(!timer_running){
- timer_running = true;
- lastTime = lastTime + (sceKernelLibcClock()-pauseTime);
- }
- }
- void Timer::stop(){
- if(timer_running){
- timer_running = false;
- pauseTime = sceKernelLibcClock();
- }
- }
- void Timer::reset(){
- lastTime = sceKernelLibcClock();
- pauseTime = lastTime;
- }
- bool Timer::running(){
- return timer_running;
- }
- int Timer::time(){
- if(timer_running){
- return (int)((sceKernelLibcClock()-lastTime)/1000);
- }else{
- return (int)((pauseTime-lastTime)/1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement