I was going to make a game with C++, and I want´d a timer to it.
Is there any way to create a timer? (Like 2 functions, which start and stop the timer.) Oh, and it would be better, if the timer would be only in seconds, no minutes or hours counted. (Once you reach 60 seconds, it doesn´t say you have 00:01:00 of time, so I can use it with the if, else and switch "things". (Dunno the right word.)
Well...
When I´m trying to create it, it gaves this kind of errors:
1 2 3
error C2065: 't' : undeclared identifier
Game.cpperror C2228: left of '.start' must have class/struct/union type
error C2228: left of '.getTime' must have class/struct/union type
you can declare a timer before your main function so you can see the timer globally and then you start it in the main function.
I mean something like this:
1 2 3 4 5 6 7 8
timer t;
// write here other functions that need timer visibility
int main() {
t.start();
// write here other code
}
I hope you understand what i mean.
Declaring the timer as a global object you can see it in the main function and also in the other functions.
that was wrong because if the timer is running returns a time interval in seconds but if the timer is not running it returns a time interval in milliseconds.