English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm making a small game and I want some text to show up for a certain amount of time, and then be cleared off with the
system("cls"); command without any user interaction. How would I do this?

2007-04-22 15:12:28 · 5 answers · asked by System 2 in Computers & Internet Programming & Design

5 answers

The easiest way is to use a Sleep(milliseconds) function. For example:
Sleep(2000)
will pause the program for 2 seconds and resume the execution.
You would have to include "windows.h" if you are working in Visual Studio

2007-04-22 16:17:24 · answer #1 · answered by Bohdan 2 · 0 0

The simplest way would be to just do a 'for' or 'while' loop that does nothing, like this:

unsigned int t;
(print message)
for (t=0;t<10000;t++) {}
// don't forget the braces above
(clear screen)

unsigned int t;
(print message)
t=0;
while (t<10000)
t++; // don't need braces
(clear screen)

Unfortunately, the speed of the loop varies with the speed of the computer.
If you're programming in DOS with the Turbo C++ 3.0 compiler, then you can use the delay() function specified in DOS.H.

There's also the time functions in TIME.H
You would get the time with a function, and then use a 'while' loop that polls the time function until a certain number of seconds has elapsed.

2007-04-22 22:49:03 · answer #2 · answered by Balk 6 · 0 0

I would print something on the screen without printing a caridge return and line feed character.

Then wait for few seconds.

Then print an equal number of backspace characters......

2007-04-22 22:15:43 · answer #3 · answered by tkquestion 7 · 0 0

u might want to look at the documentation for the time.h header file

2007-04-22 22:20:59 · answer #4 · answered by Anonymous · 0 0

maybe this site can help you...


http://www.cprogrammingdock.serverspeople.net


gud luck!

2007-04-22 22:53:48 · answer #5 · answered by «iTaChi♫ 3 · 0 0

fedest.com, questions and answers