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

Spinning!


Carim123
 Share

Recommended Posts

Simple little tut, on spinning. This is just direct from IP…

In frmMain_KeyUp add...

```
    ' Spinning
    If KeyCode = 36 Then
    Call Spin
    End If
```
36 is the Home key. You can change it to whatever you like.
I have it in KeyUp, so you can't spin like a madman, but if you want it in _KeyPress, go ahead. I haven't tried it, though. ;p

Now, in modDatabase…(or pretty much any module you like, if you want to organise your code. I just have mine in modDatabase.)

Add at the bottom...

```
Public Function Spin()
Dim d As String
    d = GetPlayerDir(MyIndex)

            If Player(MyIndex).Dir = DIR_DOWN Then
                Call SetPlayerDir(MyIndex, DIR_LEFT)
                If d <> DIR_LEFT Then
                    Call SendPlayerDir
                End If
            ElseIf Player(MyIndex).Dir = DIR_LEFT Then
                Call SetPlayerDir(MyIndex, DIR_UP)
                If d <> DIR_UP Then
                    Call SendPlayerDir
                End If
            ElseIf Player(MyIndex).Dir = DIR_UP Then
                Call SetPlayerDir(MyIndex, DIR_RIGHT)
                If d <> DIR_RIGHT Then
                    Call SendPlayerDir
                End If
            ElseIf Player(MyIndex).Dir = DIR_RIGHT Then
                Call SetPlayerDir(MyIndex, DIR_DOWN)
                If d <> DIR_DOWN Then
                    Call SendPlayerDir
                End If
            End If
End Function

```
And, that's it. Now, with whatever key you've specified, just hit that, and you'll spin.
No credit is required; just don't claim as your own. ;p
Link to comment
Share on other sites

@RyokuHasu:

> It flips your direction.
>
> If you are getting attacked from 2 sides this helps… I think..

Yep, exactly that.

@beckymegan:

> I actually laughed when I saw this post (and then I added it and sat staring at my girl spin for 5 minutes). Great/cute little code

Hah, same. xD
Link to comment
Share on other sites

for the game I'm making, this is VERY useful. I'd like to know, if you could edit this so that 1, 2, 3, and 4 on the keypad and the other part make you face the direction w/o moving. Like you press 1 and ur instantly facing up, 2 and ur facing right, 3, down, and so on. It's good to have this in my game because your going to be running from zombies, and you cant use that extra tile to turn and face them, you could just turn and shoot :D

THANKS!!!
Link to comment
Share on other sites

@Whackeddie99:

> for the game I'm making, this is VERY useful. I'd like to know, if you could edit this so that 1, 2, 3, and 4 on the keypad and the other part make you face the direction w/o moving. Like you press 1 and ur instantly facing up, 2 and ur facing right, 3, down, and so on. It's good to have this in my game because your going to be running from zombies, and you cant use that extra tile to turn and face them, you could just turn and shoot :D
>
> THANKS!!!

I won't do that for you, but I'll give you a hint.

In the same KeyUp part, find the Key Code Constants for the keys you want, and simply add:

If KeyCode = KEYCODEHERE Then
      Call SetPlayerDir(MyIndex, DIR_WHATEVER)
      Call SendPlayerDir
End If
Link to comment
Share on other sites

  • 2 weeks later...
@7:

> I won't do that for you, but I'll give you a hint.
>
> In the same KeyUp part, find the Key Code Constants for the keys you want, and simply add:
>
> If KeyCode = KEYCODEHERE Then
>       Call SetPlayerDir(MyIndex, DIR_WHATEVER)
>       Call SendPlayerDir
> End If

YAY!!! Thanks for not telling me how to do it and forcing me to teach myself! I figured it out lol, I'm making progress! Now it works fine, and I used Home, Delete, End, and Page Down as the spinning keys :D
Link to comment
Share on other sites

  • 4 weeks later...
This is how I did it. It does take away the ability to set walk speed with shift, but this was fine for me.

In the client under modGameLogic find the sub ProcessMovement and change it to look like this.

```
            ' Check if player has the shift key down for running
            If ShiftDown Then
                Call SendPlayerDir
                Player(MyIndex).Moving = MOVING_RUNNING
                Exit Sub
            Else
                Player(MyIndex).Moving = MOVING_WALKING
            End If

```
Link to comment
Share on other sites

  • 8 months later...
Im very sorry for the necro post. But anyone using this may want to add a check if the player is moving. Cause this can cause a bug where the player gets stuck.

Edit:
Got the fix…

Use this as your input code:
```
  ' Spinning
            Select Case keyCode
                Case vbKeyHome
                    If Player(MyIndex).Moving = False Then
                            Exit Sub
                        Else
                            Call Spin
                        End If
                End Select
```
Link to comment
Share on other sites

  • 8 months later...
  • 1 month later...
This is sleeker!

```
Public Function Spin()

Select Case GetPlayerDir(MyIndex)

Case DIR_UP

Call SetPlayerDir(MyIndex, DIR_RIGHT)

Case DIR_DOWN

Call SetPlayerDir(MyIndex, DIR_LEFT)

Case DIR_LEFT

Call SetPlayerDir(MyIndex, DIR_UP)

Case DIR_RIGHT

Call SetPlayerDir(MyIndex, DIR_DOWN)

End Select

End Function
```
Link to comment
Share on other sites

> ```
>
> Dim d As String
>
> d = GetPlayerDir(MyIndex)
>
> ```
>
> I'm trying to figure out why he used a string for that, haven't used eclipse for months, nor do I really want to look, but I'm pretty sure GetPlayerDir() didn't return a string value.

Yeah, it doesn't.
Link to comment
Share on other sites

  • 6 months later...

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...