Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Knox on Sat 02/03/2013 21:14:05

Title: Keyboard Movement: Holding down the key in Tap Mode
Post by: Knox on Sat 02/03/2013 21:14:05
I was searching the threads to see if this problem has been posted before and only seemed to find this thread (with no response):
http://www.adventuregamestudio.co.uk/forums/index.php?topic=46041.msg617865#msg617865

Ive come up with a solution, however for some reason it doesnt seem to work when I press the PageUp or PageDown keys (diagonal up right, diagonal down right)
Code (ags) Select

//IN REP EXEC:
void holdKey_TapMode()
{
  if (bKbdTap)
  {
    if (!bPressMode_Temp && (IsKeyPressed(eKeyRightArrow) || IsKeyPressed(eKeyLeftArrow) || IsKeyPressed(eKeyUpArrow) || IsKeyPressed      (eKeyDownArrow) || IsKeyPressed(eKeyPageUp) || IsKeyPressed(eKeyPageDown) || IsKeyPressed(eKeyEnd) || IsKeyPressed(eKeyHome)))
    {
      iKbdPressTimer++;
      if (iKbdPressTimer >= 10)
      {
        KeyboardMovement.SetMode(eKeyboardMovement_Pressing);
        bPressMode_Temp = true;
        iKbdPressTimer = 0;
      }
    }
    else if (!IsKeyPressed(eKeyRightArrow) && !IsKeyPressed(eKeyLeftArrow) && !IsKeyPressed(eKeyUpArrow) && !IsKeyPressed(eKeyDownArrow) && !IsKeyPressed(eKeyPageUp) && !IsKeyPressed(eKeyPageDown) && !IsKeyPressed(eKeyEnd) && !IsKeyPressed(eKeyHome))
    {
      if (bPressMode_Temp)
      {
        bPressMode_Temp = false;
        KeyboardMovement.SetMode(eKeyboardMovement_Tapping);
      }
    }
  } 
}


What it does is if the user holds down on the key while in tap mode, it will temporarily switch to the press mode so the ugly stuttering no longer happens.

Only thing is, for some reason it doesnt work for those 2 keys (or directions). What am I doing wrong?

Ok, found the prob! Is this a good way of solving the issue?