Tuesday 27 October 2009

Well, I have managed to improve the joystick handling when playing the game so now it should be playable (ignoring difficulty issues) by using a joystick or game-pad.

Even an analog joystick should work nicely (touch wood), as it should allow the cross-hairs to move at pretty much any speed up to the maximum speed :)

Instead of relying on SDL joystick events, I am now checking the joystick axii in the render routine like so:

Function  GetJoyAxisValue(Const AJoystick        : PSDL_Joystick;
                          Const AAxis,AThreshold : Integer) : Single;
Begin
    Result := SDL_JoystickGetAxis(AJoystick,AAxis);
    If Result < AThreshold Then
        Result := 0
    Else
        Result := Result / 32768;
End;
{..}
        If FHasJoystick Then
        Begin
            FCrossHairs.x := FCrossHairs.x + cMoveSpeed * GetJoyAxisValue(TGame(FOwner).JoyStick,cJoyAxis_X,cThreshold) * ATimeSlice;
            FCrossHairs.y := FCrossHairs.y - cMoveSpeed * GetJoyAxisValue(TGame(FOwner).JoyStick,cJoyAxis_Y,cThreshold) * ATimeSlice;
        End
 
Get it here while it's still hot ;-)

http://www.paulsbitsandbytes.webatu.com/dod/dod_download.php

cheers,
Paul

No comments:

Post a Comment