• Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Simple WASD-key Functionality

Simple WASD-key Functionality 2017-05-18

Hello there! I'm providing a simple guide on how to include WASD-key functionality to your fan-game!

If you've played any game on the PC, you'll know that one key feature is that movement tends to default to using WASD and not the arrow keys, so I've created a guide on how to include WASD as an alternative (and not as a replacement for those who are used to arrow keys!)

I really hope games start including this feature, along with keyboard text entry. It helps makes fan-games more localized to PC's rather than sticking to outdated methods! It just feels more natural to have these little quality of life fixes.

Something to note is that you can edit controls, but while changing WASD to include movement is essential, there's more to it than that; otherwise you'll never be able to A or D when using the keyboard text input feature, and that's not good! using keyboard for text entry would inherently mess with WASD keys, as the A and D would not function as text input, but rather movement left and right - this guide puts in a measure in the text entry section to disable the movement functionality of A and D during the text input screen, and when you're done, it reverts to normal!


Step 1


Find the line:
Code:
class Window_TextEntry_Keyboard < Window_TextEntry

Directly under "def update" add the line:
Code:
$game_switches[X] = false
* Replace "x" with whatever switch you are not using! (make sure its the same variable you use later!)

Then find the line:
Code:
ret=@scene.pbEntry

A few lines below, find the line:
Code:
@scene.pbEndScene

Now add in this line underneath it:
Code:
$game_switches[X] = true
*Note, this "x" uses the same variable you used earlier! It has to be the same so it's switching on and off!


Step 2


Use ctrl+shift+f and find:
Code:
def self.buttonToKey(button)

Change the lines to look like this:
Code:
when Input::DOWN
      return [0x28,0x53] # Down, S
    when Input::LEFT
      if !$game_switches || !$game_switches[X]
        return [0x25] # Left
      else
        return [0x25,0x41] # Left, A
      end
    when Input::RIGHT
      if !$game_switches || !$game_switches[X]
        return [0x27] # Right
      else
        return [0x27,0x44] # Right, D
      end
    when Input::UP
      return [0x26,0x57] # Up, W
*The X is the exact same variable as in step 1!
*What I did here was add in functionality to not only use the original arrow keys, but to also include the WASD-keys. However, the functionality ceases whenever you activate the switch, and in the first step we included measures to use the switch to, when you input text with a key-board, remove the A and D function, and when inputting the text ends, it reverts to normal WASD functionality.
Credits
There's no need for credits for such a simple fix!
But if you want to give me a shout-out or a simple thanks you can credit it to:
Radical Raptr
Author
Radical Raptr
Views
2,248
First release
Last update
Rating
5.00 star(s) 1 ratings

More resources from Radical Raptr

Latest reviews

I never thought about this feature before someone requested it in my game, but it's so easy to impliment that now it's going in all my games. Thank you!
Back
Top