Hello, i created some simple movement code. I know this is probably extremely bad code, but im just learning c++ so bear with me.
if(dbDownKey())//do something on user input
{
Direction = 4;
y = y + speed;
dbPlaySprite ( i, 1, 4, AD );
dbSprite ( i, x , y, i );;
}
if(dbUpKey())//do something different on different user input
{
Direction = 3;
y = y - speed;
dbPlaySprite ( i, 13, 16, AD );
dbSprite ( i, x , y, i );
}
if(dbLeftKey())//do something different on different user input
{
Direction = 1;
x = x - speed;
dbPlaySprite ( i, 5, 8, AD );
dbSprite ( i, x , y, i );
}
if(dbRightKey())//do something different on different user input
{
Direction = 2;
x = x + speed;
dbPlaySprite ( i, 9, 12, AD );
dbSprite ( i, x , y, i );
}
It is hard to explain the problem. Basically the movement works fine, but i believe that when i stop pressing a direction the commands stop before the animation is fully finished. When i start walking in a new direction it starts playing the frames left over from the last direction and messes up my movement. I think that is what happening im not sure. Again very hard to explain. This youtube video shows the bug im getting. I hope someone can provide me with some help or code.
Thanks in advance.
http://www.youtube.com/watch?v=a8NQV8FZmhU