Hey all,
I've elected to write a console hangman game and I've completed it just fine. However, one thing is evading my logic as to why it wouldn't work. I want it to "appear" to LOAD GAME" at the beginning like so: "LOADING GAME....." The total wait time I want it to be is 5 seconds with each 'period' appearing at 1 sec. intervals.
Currently, LOAD GAME appears and immediately goes into the game without any "wait(n)" intervals.
Why won't it work? Here is the relevant parts of my code:
#include <iostream>
#include <string>
#include<conio.h>
#include <ctime>
#include <map>
using namespace std;
void wait (int seconds)
{
clock_t endwait;
endwait = clock() + seconds * CLOCKS_PER_SEC;
while (clock() < endwait) {}
}
int main()
{
int seconds;
int countdown = 5;
cout <<"\n\n\n Game will begin in 5 seconds" <<endl;
cout <<"\n\n Press ENTER to load the game:\n" <<endl;
getche();
cout << "\n\t\t\t\tLOADING GAME";
for (countdown; countdown < 5; countdown++)
{
cout <<".";
wait(1);
}
Something so simple has me pulling my hair out!
Saw this (below) on a signature that I thought was hilarious:
- ASCII a stupid question, get a stupid ANSI. -