I'm creating a simple fighter game with Allegro 5. One of my basic establishments was the possibility to use gamepads (they feel more comfortable in fighters, don't they).
The problem I encountered is that I somehow cannot make my character move (right, left) fluently when the left stick is held (position 1.0 or -1.0 on axis 0, stick 0).
Here's how I'm trying to achieve it:
event.joystick.pos == 1
event.joystick.pos == -1
This is based on keyboard movement procedure, which looks like this:
3 if( al_key_down( &
keystate, ALLEGRO_KEY_RIGHT ) )
4 if( al_key_down( &
keystate, ALLEGRO_KEY_LEFT ) )
Unfortunately, such an approach does not work.
if(gamepadstate.stick.axis) cout << event.joystick.pos; shows some float number from 0.2 to 0.7 (approximately, hardly ever reaches 1) when I move the stick. The number is always non-negative, no matter if I flick my stick left or right.
Position output is valid under
if( event.type == ALLEGRO_EVENT_JOYSTICK_AXIS )
but there's no fluid move either. One object (character) position change on one flick, nothing more when held (which is completely expected ofc).
And finally some questions.
Is there anything I missed?
Is my approach any good?
What don't I understand here?
Could I get any advice on how to move my character with gamepad stick?
Thanks in advance. Sorry if I'm unclear anywhere.