Jump to content
  • Advertisement

Archived

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

kevx25

Time?

This topic is 5560 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

Hi i''m writing a little conosle application with C++, which is virutal pet "tamagotchi, and i;m stuck with a problem. I need to know how to write the command where after each hour it adds a certain amount of value to a varible. Is this method called ticks or something, can someone guide me on how to do this?? Thanks Kev

Share this post


Link to post
Share on other sites
Advertisement
If you do this by ticks, you have to call timeGetTime(), this function return the miliseconds since the machine started, you have to save a time_start variable and in your update, check the miliseconds that have passed since time_start.

Hope this help

---------------------------------------------
If God with me, Who against me?
Sitio de desarrollo de videojuegos en español
Digital Moon Studio...

There is no spoon

[edited by - NeonGE on July 2, 2003 1:46:21 PM]

Share this post


Link to post
Share on other sites
What i''m trying to do is for every hour or so it adds 1 to the hunger varible. can any one show me how to write the statement or syntax for it please, ive been struggling with this.

Share this post


Link to post
Share on other sites

timebeginperiod(1);
int start_time=timegettime();
int current_time=start_time;
int hunger=0;

while(true)
{
current_time=(timegettime()-start_time);
hunger+=current_time/3600000;
}

timeendperiod(1);


Note this is just one (probably clumsy) way to do it. The "magic number" of 3600000 is the number of milliseconds in an hour since timegettime returns milliseconds.

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.

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!