A little joystick weirdness
Posted: Thu Jan 18, 2018 11:02 am
I've noticed a glitch in my BASIC game.
The main character is moved with a joystick. I've introduced some kind of inertial damping in its movements, controlled by a variable. So when the joystick is idle, the variable is set to 1. When the joystick is moved, the damping variable is checked. If it's 1 (the joystick was idle) a little delay is introduced and the variable is set to 0. If it's 0 (the joystick was already "not idle") there is no delay. Then the character is moved across the screen.
Everything works OK when you move the character UP, DOWN, LEFT or RIGHT. There is a slight delay with the first movement, but if you keep the joystick in the same direction, the following movements are, let's say, at a correct speed. Which is what I want. The problem is with diagonal movements.
With diagonal movements, the character is moved in the correct location alright (ie. up+left; up+right; down+left or down+right), but at WARP SPEED (compared to the "main" up/down/left/right movements. Not only there is no noticeable "first movement" damping, but all the subsequent movement along the diagonal are MUCH faster and barely controllable.
I've been through the code carefully, and all the instructions are executed for all 8 movements. I have found no reason to explain why the diagonal moves are much faster.
Any ideas?
The main character is moved with a joystick. I've introduced some kind of inertial damping in its movements, controlled by a variable. So when the joystick is idle, the variable is set to 1. When the joystick is moved, the damping variable is checked. If it's 1 (the joystick was idle) a little delay is introduced and the variable is set to 0. If it's 0 (the joystick was already "not idle") there is no delay. Then the character is moved across the screen.
Everything works OK when you move the character UP, DOWN, LEFT or RIGHT. There is a slight delay with the first movement, but if you keep the joystick in the same direction, the following movements are, let's say, at a correct speed. Which is what I want. The problem is with diagonal movements.
With diagonal movements, the character is moved in the correct location alright (ie. up+left; up+right; down+left or down+right), but at WARP SPEED (compared to the "main" up/down/left/right movements. Not only there is no noticeable "first movement" damping, but all the subsequent movement along the diagonal are MUCH faster and barely controllable.
I've been through the code carefully, and all the instructions are executed for all 8 movements. I have found no reason to explain why the diagonal moves are much faster.
Any ideas?