Getting last number of a integer?

Hey I have a question and a problem.
I'm counting frames in my c++ code, 1 frame = 0.01 second usually.

Between ACTION and ACTION2 there is about 72 frames (MAX), it's random every time you do different movements in this game I reset the frame counter when it hit ACTION2. So you press on a key... the frame counter starts (ACTION counting up to a high value -> boom it resets the value to 0.)

When I hit ACTION2, It will count quickly to 1 or 2 frame(s) depending what I need. Now there is a problem that I have with this code when I hit the very last frame of ACTION e.g. 72 BEFORE ACTION2 frame counter action occurs it will CHANGE the movement. Aka if BOTH are together (ACTION frame counter and ACTION2 frame counter) it will mess the movement up. I'd want the last number everytime of this integer (ACTION frame counter), BEFORE it resets to 0. And by that disable the code on that LAST frame on this integer. And have it only enabled when it hits on ACTION2 (frame 1 or 2).

Thanks in advance, hopefully someone will understand me!
I'm not clear on the problem is, but I'd expect you to use a ring buffer of size 72 to hold your frames. You always place the next frame in the next position, resetting is just a matter of changing the end pointer value.

What data structure are you using to hold your frames?
I just loop variable++;
In a function that loops.

I've never used ring buffer before, I googled and found some.

Since I said and noticed I don't know the random number that occurs everytime since then we need to hook the last frame by searching for it before it resets.

As you said there, that may work, but if it's possible to get the last frame is my question, not to do if ( I_know_this_random_number ) { code here } I meant that if we can get the last number, without knowing what it will be.

By the way now yesterday I found a solution for my code, to check for a certain thing (movement thing) in this game, before ACTION2 occured, it was just to measure height in movement (ACTION = ground, ACTION2 before ground (air)) and I got the thing I wanted to do, disable the code before ACTION2 occured / ACTION stopped / resetted. So I'll mark this thread as solved now, thanks for your reply, still I may be interested to know more about "ring buffer" and what you really meant and if ring buffer would be a solution #2 that could also work also.
Last edited on
Topic archived. No new replies allowed.