Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

mrtie_dye

Display timer

This topic is 5531 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 been teaching myself c from a book for about 6 months and have started on my first project. It is a simple text based game where you can pick up some items and do things with them. I have used almost every command taught in the book I am learning from, from printf to random access files and more. Still very basic, though. Anyway, lets say somewhere in the game I want the user to pick up an item and have a certain amount of time to do something with it. Or go into a room and a timer starts when they interact with something in the room, or whatever. I want the timer to display on the screen in normal text mode, and update itself. Where could I go to learn how to do this? I don''t want someone elses code, I want to learn it myself. Not only the timer itself, but how to get text to print over itself without affecting the other text on the screen. I am hoping this is way more complicated than I think, and that I will have learn all sorts of stuff about c to do it. I want to learn all this stuff, I just don''t know where to begin. Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure how to tell you without telling you, but I'll give it a shot

there are functions in "time.h" that allow you to read the clock time. You can store the start time, when you entered the room. Then subtract the current time to find elapsed time.

The other way, if you are using Win32, you can create a timer(?),(look up the function in msdn.microsoft.com). Then catch the WM_TIMER messages, and update your clock accordingly. That will only work for MFC or Win32, not Win32 console.

The function "gotoxy()" will allow you to place the cursor where your timer is. Then redisplay the timer to erase it. Make sure you add some white space if your time shrinks.

(for some reason time.h got erased... )




[edited by - dede on May 3, 2003 12:00:54 PM]

Share this post


Link to post
Share on other sites
Thanks for the info. All this time, time.h was just sitting there in my include directory and I had no idea what it did. Now maybe I can find out!!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!