trying to make count down clock in game

currently make a game and i need a clock timer to count down once it reaches zero game over screen appears etc etc anyway i got what i think should work but it doesn't draw in game all it does is do a count down in black cmd window how would i get it to work in game >.<?


here is the functions
in my main i have
1
2
3
4
5
6
7
8
9
10
11
12
13
DrawString("Time: ",440,48,2.2);
{

	{
		for (n=60; n>0; n--)
		{
			printf ("%d\n",n);
			wait(1);
		}
	}


}



AND THE FUNCTION is

1
2
3
4
5
6
7
8

void wait ( int seconds )
{
  clock_t endwait;
  endwait = clock () + seconds * CLOCKS_PER_SEC ;
  while (clock() < endwait) {}
}



but i need it to print or draw into the spot were Drawsting("timer") is not in the black cmd window sooooooo any ideas?
1
2
3
4
5
6
7
8
9
10
11
12
13
DrawString("Time: ",440,48,2.2);
{

	{
		for (n=60; n>0; n--)
		{
			printf ("%d\n",n);
			wait(1);
		}
	}


}


This is not a function,
functinos have return type specified.

Unfortunetly that is all I understood in your question.

If you could spell your english a litle bit better and use commas and dot's in your question maybe someone would understand your problem.

Cheers!
sorry about the grammar. Let me try again =D.

okay i want to make a function that will be active when my game is in it's play game state, that function needs to contain a count down timer.

The timer is like one of those count down in old school racing games, where you have to get to the next check point in order to gain more time, once the time runs out its game over. So far all i have managed to do is make it count down from 60 in the black CMD window that pops up behind my .exe while i am using VS2010. How do i change it so that it will work like one of those old racer count downs....any advice....how this was clearer =D
See how you learned to write English :D LOL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <ctime>
#include <iostream>
using namespace std;

inline void wait ( short seconds )
{
  clock_t endwait;
  endwait = clock() + seconds * CLOCKS_PER_SEC;
  while (clock() < endwait);
}


inline void CountDown()
{
	for (short minutes = 1; minutes >= 0; --minutes)
	{
		for (short seconds = 59; seconds >= 0; --seconds)
		{
			cout << minutes << ':' << seconds;
			wait(1);
			system("CLS");
		}
		wait(60);
	}
}


int main()
{
	CountDown();
	std::cin.ignore();
	return 0;
}
yep was a rushed questions, my bad and thanks for this it works a charm with a bit of tweaking =D
Topic archived. No new replies allowed.