I think the way I would implement this is to have two variables, one for the direction on the frame previous to the current one (say PREVDIR%), one for the direction on the current frame (say CURRDIR%). For initialization, set CURRDIR% to zero, indicating the sprite is stationary. In the superloop, have two lines like
PREVDIR%=CURRDIR% CURRDIR%=BUTTON() AND (#LEFT OR #RIGHT OR #UP OR #DOWN)Now, if CURRDIR% is one of the four values #LEFT, #RIGHT, #UP, or #DOWN, then your sprite is moving in a cardinal direction and the sprite's appearance needs to correspond to that. If CURRDIR% is nonzero, but not a cardinal direction, then it is a diagonal direction. There are two cases to consider when the sprite is moving diagonally. First, if PREVDIR% is nonzero, then you are in a situation like, the user has been holding 'down', then just started holding 'right' at the same time. In this case, do not change the appearance of the sprite. Second, if PREVDIR% is zero, then the user went from stationary directly to moving diagonally. You have to choose which cardinal direction you'd prefer for the appearance of your sprite. I think I would choose left/right over up/down, since the screen is wider than it is tall, but it is your choice.