EvilZone

Programming and Scripting => C - C++ => : iloveks December 17, 2012, 07:17:31 PM

: time.h
: iloveks December 17, 2012, 07:17:31 PM
Hi i wants to know how to use time.h
i waana to use it for making a c++ game which has 30 sec deadline so how should i use it.
: Re: time.h
: geXXos December 17, 2012, 07:19:56 PM
http://www.cplusplus.com/reference/ctime/

Welcome at EZ

Edit*

@iloveks
 
What this poll is about, which one is better in what ? more easy? develop apps,games,general programming ? with which one to start ?

They are all C to me.

Anyway i vote for "C" having in mind the fact that all the others are easier to get later.
: Re: time.h
: Kulverstukas December 17, 2012, 09:44:32 PM
Pole unrelated. Removed.
Try this (https://www.google.lt/search?hl=en&safe=off&client=firefox-a&hs=TX3&tbo=d&rls=org.mozilla%3Aen-US%3Aofficial&q=how+to+use+timer+in+c%2B%2B&oq=how+to+use+timer+in+c%2B%2B&gs_l=serp.3..0j0i8i30l2j0i22l7.27308.29474.0.30050.16.13.0.3.3.1.188.1210.9j4.13.0.les%3Bernk_timediscountb..0.0...1c.1._IeFy4XC4IY).
: Re: time.h
: Xires December 19, 2012, 03:17:14 AM
man time.h

The basic idea, for creating a timer, is to create something to store the time.  Typically this is a struct of type 'time_t'.  You then grab the current time via a call to 'time()', usually passing NULL as the argument.  All of this is done before you begin a timer loop.  The timer loop is relatively easy as well; just keep a temporary copy of the current time that you update continuously.  When you've reached the time limit(meaning your first saved time & your current time are 30 seconds apart, in this case), you end the timer loop.

There are some better methods as well, such as actually using an alarm, or setting a system timer, etc.

Good luck.