Travis13 Expert Cheater
Reputation: 0
Joined: 17 Feb 2007 Posts: 199
|
Posted: Mon Dec 01, 2008 2:23 am Post subject: [C++] Timer + source code (good for beginners like me) |
|
|
Hey guys, i jsut made a little program and I'm proud of it
I had the timer part done for a while but I put more user control into it by asking for the delay and everything. hope it helps someone.
Code: | #include <iostream>
#include <windows.h>
using namespace std;
bool Exit = false;
bool repeatseconds = false;
bool repeatminutes = false;
bool repeathours = false;
int hours = 0;
int seconds = 0;
int delay;
void timerseconds()
{
while(repeatseconds == false)
{
seconds ++;
Sleep(delay * 1000); // change the delay higher or lower to test out the minutes and hours wihtout having to wait a long time
cout << "The # of seconds is: " << seconds << endl;
if(GetAsyncKeyState(VK_F2))
{
int minutes = seconds / 60;
int hhours = minutes / 60;
int mmodulus = minutes % 60;
int smodulus = seconds % 60;
repeatseconds = true;
cout << "\n\nTime counted up to: " << hhours << " hour(s) " << mmodulus << " minute(s) and " << smodulus << " second(s)." << endl;
}
}
}
int main()
{
SetConsoleTitle(" ~*~*~*~*~*~*~*~*~*~*~ C++ TIMER ~*~*~*~*~*~*~*~*~*~*~");
cout << "Welcome to a c++ timer made by Travis13 of cef." << endl << endl << endl;
cout << "Please enter the delay (in seconds) you want between each number." << endl << endl;
cin >> delay;
cout << "\n";
cout << "F1 = start" << endl;
cout << "F2 = stop" << endl;
cout << "F3 = EXIT" << endl;
cout << "\n" << endl;
while (Exit == false)
{
if(GetAsyncKeyState(VK_F1))
{
timerseconds();
}
else if(GetAsyncKeyState(VK_F3))
{
Exit = true;
}
}
return 0;
} |
So ya play with the hotkeys do w/e u want, but TRY TO LEARN OFF OF IT.
edit: no one likes it?
_________________
Learning C++, trying, failing, never gonna give up tho  |
|