Jump to content
  • Advertisement
Sign in to follow this  
rycon

Title screen pause

This topic is 4816 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a title screen for my game that I want to display for a few seconds and then go on. What is a good way to do this. Keep in mind this is a console application, I am currently using system("pause"), which does the job, but the user has to hit a key to continue. The only thing I can think of is to just use a loop and kill time, is there a more elegant solution to this.

Share this post


Link to post
Share on other sites
Advertisement
Included in the Windows.h header is the sleep() function, which takes in its argument the minimum number of milliseconds to pause the thread.

EDIT: Too fast for me. :)

Share this post


Link to post
Share on other sites
You can also make your own delay function using <ctime> (or <time.h> in C).

#include <ctime>

void delay( long int milliseconds )
{
time_t current = clock();
time_t end = current + milliseconds;

for ( ; current <= end; )
current = clock();
}

// another way - they are basically the same
/* void delay( long int milliseconds )
{
time_t end = clock() + milliseconds;

while ( 1 )
if ( clock() == end )
break;
}
*/


int main()
{
delay( 4000 );
return 0;
}






Edit: You will probably never want a delay anywhere near the extent of a long int, so you can just use a regular int.

Edit: I just read that the resolution of clock() is 1 second, so the use of "milliseconds" is unnecessary. Maybe change it to seconds, but it makes no difference in the functionality.

Edit: Unless what I read proves to be false.

[Edited by - skulldrudgery on May 15, 2005 5:45:13 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!