Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

WASD Movement.


sir zach
 Share

Recommended Posts

This allows people to move using WASD. It is all Client Side.

Side Note: It does have errors with the chat box because of the characters its using. But I have a fix for this, [here](http://www.touchofdeathforums.com/smf/index.php/topic,28926.0.html). It is also coded around that other tutorial. If you need help and don't want to use the other code, just let me know and I can edit this code to suit your needs.

**All of the edits are in modGameLogic.**

1\. Find:

```
            If KeyCode = vbKeyUp Then
                DirUp = True
                DirDown = False
                DirLeft = False
                DirRight = False
            End If

            If KeyCode = vbKeyDown Then
                DirUp = False
                DirDown = True
                DirLeft = False
                DirRight = False
            End If

            If KeyCode = vbKeyLeft Then
                DirUp = False
                DirDown = False
                DirLeft = True
                DirRight = False
            End If

            If KeyCode = vbKeyRight Then
                DirUp = False
                DirDown = False
                DirLeft = False
                DirRight = True
            End If
```

Replace with:

```
            If KeyCode = vbKeyUp Or (KeyCode = vbKeyW And frmMirage.txtMyTextBox.Visible = False) Then
                DirUp = True
                DirDown = False
                DirLeft = False
                DirRight = False
            End If

            If KeyCode = vbKeyDown Or (KeyCode = vbKeyS And frmMirage.txtMyTextBox.Visible = False) Then
                DirUp = False
                DirDown = True
                DirLeft = False
                DirRight = False
            End If

            If KeyCode = vbKeyLeft Or (KeyCode = vbKeyA And frmMirage.txtMyTextBox.Visible = False) Then
                DirUp = False
                DirDown = False
                DirLeft = True
                DirRight = False
            End If

            If KeyCode = vbKeyRight Or (KeyCode = vbKeyD And frmMirage.txtMyTextBox.Visible = False) Then
                DirUp = False
                DirDown = False
                DirLeft = False
                DirRight = True
            End If
```

2\. Find:

```
              ' Check to make sure they aren't trying to auto do anything
                If GetAsyncKeyState(VK_UP) >= 0 And DirUp Then
                    DirUp = False
                End If
                If GetAsyncKeyState(VK_DOWN) >= 0 And DirDown Then
                    DirDown = False
                End If
                If GetAsyncKeyState(VK_LEFT) >= 0 And DirLeft Then
                    DirLeft = False
                End If
                If GetAsyncKeyState(VK_RIGHT) >= 0 And DirRight Then
                    DirRight = False
                End If
                If GetAsyncKeyState(VK_CONTROL) >= 0 And ControlDown Then
                    ControlDown = False
                End If
                If GetAsyncKeyState(VK_SHIFT) >= 0 And ShiftDown Then
                    ShiftDown = False
                End If
```

Replace with:

```
                ' Check to make sure they aren't trying to auto do anything
                If GetAsyncKeyState(VK_UP) >= 0 And DirUp Then
                If GetAsyncKeyState(VK_W) >= 0 Then
                    DirUp = False
                End If
                End If
                If GetAsyncKeyState(VK_DOWN) >= 0 And DirDown Then
                If GetAsyncKeyState(VK_S) >= 0 Then
                    DirDown = False
                End If
                End If
                If GetAsyncKeyState(VK_LEFT) >= 0 And DirLeft Then
                If GetAsyncKeyState(VK_A) >= 0 Then
                    DirLeft = False
                End If
                End If
                If GetAsyncKeyState(VK_RIGHT) >= 0 And DirRight Then
                If GetAsyncKeyState(VK_D) >= 0 Then
                    DirRight = False
                End If
                End If
```
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...