This code animates my main game sprite by increasing the animation frame. First I check if the character is moving, then I increase the animation counter until it reaches the desired speed, and then if so, I increase the animation frame.
How can I make it more elegant and optimised in terms of speed?
if (moving){
anispeed++;
if (anispeed==animaxspeed){
anispeed=0;
animationframe++;
if (animationframe==3) animationframe=0;
}