Currently, I am creating a HTML5 game where I have implemented javascript to make my character move in response to the user pressing the arrow keys. The movement animation consists of 6 sprites.
However, I have encountered an issue where when I hold down the right arrow key, the character moves smoothly but appears to be moving too quickly. It's almost like a little bird flapping its wings so rapidly that it's challenging to make out the character's appearance.
Snippet of my code:
if (38 in keysDown) { // Player holding up
if (character.y>=0)
{
character.y -= character.speed * modifier;
position++;
if(position > NUM_POSITION)
position = 0;
}
}
In my code, I have implemented requestAnimationFrame and modifier to adjust the character's speed per second.
I am curious to know how others tackle the issue of a character appearing to move too rapidly. I am not referring to the character covering a large distance quickly because I can simply reduce the speed. I am referring to the character rapidly switching sprites, making it challenging to see unless it stops moving.