I set up a system that takes FPS into account when measuring time, so 10 fps lads don’t get an advantage over 600 fps lads. Now, I need to check if it works properly so I need to have a timer that starts counting after a certain function, and stops counting after a certain function then gives me the time in seconds.
The two functions are Setters, they are to set the enum state of a mechanical gate in the game:They have a height from which they are open, they move and after a height they are closed. They player has to enter just the right time, and as I gave heights, and use the Tick event to move the gates, needless to say that the FPS plays a huge role in the game.
So, these gates have a couple of states, but I care about two now: “CanEnter” and “TooLate”. All the game logic is set, I just need to start a timer right after the state is changed to “CanEnter” and I need to stop it, and display the time right after the state is “TooLate”. I saw timers on the net that count backwards. I need one to count forward and tell me the time.
How to do this?
Sod it, I found the way around it by incrementing the variable every time I’m after function A and printing it when I’m after function B.