This will be a simple tutorial to teach you how to add movement keys in your game.
If you would like to use different keys then the arrow keys to move this tutorial is useful for that.
This will be all client sided.
Our first step will be to stop the chat box from picking up letter key presses.
To do that we will need to:
In modGeneral, Sub SetFocusOnChat, comment out the part where it sets focus on txtMyChat:
Next head over to modGlobals and add:
Public Chatting As Boolean
Next head over to frmMain find the event "picScreen’s MouseDown: add the code:
Call SetFocusOnChat Chatting = False
Next on frmMain go to txtMyChat in vb6 use the drop down at the right and select the “click” event. Then input the code:
Chatting = True
Now is the part where we add in the actual new keys for movement. If you don’t want arrow key movement at all in your game you can just delete the arrow key movement code in the sub “CheckInputKeys”
To add the new movement in the sub CheckInputKeys in under the arrow key movement code add:
If Chatting = False Then 'Move Up (W) If GetKeyState(vbKeyW) < 0 Then DirUp = True DirDown = False DirLeft = False DirRight = False Exit Sub Else DirUp = False End If 'Move Right (D) If GetKeyState(vbKeyD) < 0 Then DirUp = False DirDown = False DirLeft = False DirRight = True Exit Sub Else DirRight = False End If 'Move down (S) If GetKeyState(vbKeyS) < 0 Then DirUp = False DirDown = True DirLeft = False DirRight = False Exit Sub Else DirDown = False End If 'Move left (A) If GetKeyState(vbKeyA) < 0 Then DirUp = False DirDown = False DirLeft = True DirRight = False Exit Sub Else DirLeft = False End If End If
For this tutorial purpose i have set the new keys to WASD. But you can use any keys you want on the keyboard just change the appropriate letters in the code we just added.
That should be it if any questions let me know!