Calculating the time between events.

Started by rich, Sat 06/01/2007 06:39:36

Previous topic - Next topic

rich

I'm creating a sort of arcade sequence. I want to be able to calculate the time in between when the user does one event to the next. For example, the time between one mouse click and the next. I will then calculate how quickly the user is pressing the mouse.

I won't have a problem creating an function that will calculate the average speed they're clicking. What I am having a problem doing is checking the time between one click and the next. I could set a variable to capture the time with each mouse click and compare it to the previous variable which captured the last time, but it appears that I can only check the clock to the hour, minute, second... but I need to check smaller increments than a second.

Is there something I'm missing? Does anyone have any suggestions?

Thanks in advance,
Rich
I'm so excited!

Gregjazz

Hmmm, well personally I'd just make a timer in repeatedly_execute that increments every game cycle when it's activated. Like:

if (timer > 0) timer ++; //so the timer is activated when it is set from its default value of 0 to 1

In fact, make the timer an array, that way you can see the times of its previous timings.

(off of the top of my head, the game cycles are default at 40 cycles per second, I believe)

SMF spam blocked by CleanTalk