| 1 | /*************************************************************************** |
| 2 | gameclock.cpp - description |
| 3 | ------------------- |
| 4 | begin : Sun May 18 19:17:34 2003 |
| 5 | copyright : (C) 2003 Michael Bridak |
| 6 | email : [email protected] |
| 7 | $Id: gameclock.cpp,v 1.1 2003/05/19 02:26:36 mbridak Exp $ |
| 8 | ***************************************************************************/ |
| 9 | |
| 10 | /*************************************************************************** |
| 11 | * * |
| 12 | * This program is free software; you can redistribute it and/or modify * |
| 13 | * it under the terms of the GNU General Public License as published by * |
| 14 | * the Free Software Foundation; either version 2 of the License. * |
| 15 | * . * |
| 16 | * * |
| 17 | ***************************************************************************/ |
| 18 | |
| 19 | #include <iostream> |
| 20 | #include "gameclock.h" |
| 21 | |
| 22 | using namespace std; |
| 23 | |
| 24 | GameClock::GameClock() |
| 25 | { |
| 26 | hours=0; |
| 27 | minutes=0; |
| 28 | seconds=0; |
| 29 | ticks=0; |
| 30 | } |
| 31 | |
| 32 | GameClock::~GameClock() |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | void GameClock::InitTime(int hrs, int min, int sec) |
| 37 | { |
| 38 | hours=hrs; |
| 39 | minutes=min; |
| 40 | seconds=sec; |
| 41 | } |
| 42 | |
| 43 | void GameClock::UpdateTime() |
| 44 | { |
| 45 | ticks++; |
| 46 | seconds++; |
| 47 | if(seconds > 59){ |
| 48 | minutes++; |
| 49 | seconds=0; |
| 50 | } |
| 51 | if(minutes > 59){ |
| 52 | hours++; |
| 53 | minutes=0; |
| 54 | } |
| 55 | if(hours > 23){ |
| 56 | hours=0; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | void GameClock::GetTime(int &hrs, int &min, int &sec) |
| 61 | { |
| 62 | hrs=hours; |
| 63 | min=minutes; |
| 64 | sec=seconds; |
| 65 | } |
| 66 | |
| 67 | int GameClock::GetTick() |
| 68 | { |
| 69 | return ticks; |
| 70 | } |