2 Replies - 1156 Views - Last Post: 13 January 2008 - 11:10 AM Rate Topic: -----

#1 ihcs50  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 02-January 08

time function

Posted 13 January 2008 - 10:22 AM

I am making a game in C where I need a function that waits a certain amount of time and if an action hasn't occurred in that amount of time, another action occurs. Does anyone have any suggestions on what to use?

This is what I need to happen:

if in n seconds (!box_clicked) then action;

This post has been edited by ihcs50: 13 January 2008 - 10:29 AM

Is This A Good Question/Topic? 0
  • +

Replies To: time function

#2 chellappa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-January 08

Re: time function

Posted 13 January 2008 - 10:55 AM

View Postihcs50, on 13 Jan, 2008 - 10:22 AM, said:

I am making a game in C where I need a function that waits a certain amount of time and if an action hasn't occurred in that amount of time, another action occurs. Does anyone have any suggestions on what to use?

This is what I need to happen:

if in n seconds (!box_clicked) then action;

please use kbhit() function .If !kbhit() in specified time give command for the next action destired.
kbhit means key boardhit .It is in conio.h
time(NULL) to note time from system clock
time _t t1,t2,diff;
Was This Post Helpful? 0
  • +
  • -

#3 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4309
  • View blog
  • Posts: 12,088
  • Joined: 18-April 07

Re: time function

Posted 13 January 2008 - 11:10 AM

I just wanted to note that kbhit is not part of the ANSI standard and so make sure that your compiler supports it before completely relying on it. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1