Skip to content

Instantly share code, notes, and snippets.

@arthurwolf
Created December 1, 2014 23:13
Show Gist options
  • Save arthurwolf/ba9e2adae88e9c79ee6c to your computer and use it in GitHub Desktop.
Save arthurwolf/ba9e2adae88e9c79ee6c to your computer and use it in GitHub Desktop.
// Called a great many times per second, to step if we have to now
inline void tick() {
// increase the ( fixed point ) counter by one tick 11t
fx_counter += (uint32_t)(1<<16);
// if we are to step now 10t
if (fx_counter >= fx_ticks_per_step)
step();
};
}
becomes
// Called a great many times per second, to step if we have to now
inline void tick() {
// increase the ( fixed point ) counter by one tick 11t
fx_counter += fx_steps_per_tick
// if we are to step now 10t
if (fx_counter >= 2^32 or whatever)
step();
};
}
@arthurwolf
Copy link
Author

tick(){
counter += 1
if( counter >= target ){
do a step
counter -= target
}
}

becomes :
tick(){
counter += increment
if( counter >= 1 ){
do a step
counter -= 1
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment