• Announcements

Archived

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

Time?

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 on other sites
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...

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

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 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.

• Forum Statistics

• Total Topics
628278
• Total Posts
2981785

• 10
• 11
• 17
• 13
• 9