Results 1 to 3 of 3

Thread: making a character move

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2011
    Posts
    118

    making a character move

    Hello,

    This is actually not really a question about vb, but about how to make a code.
    I'm making a RPG game and I want to make my character have "normal" movement. The problem is actually when I just hold down one of my movement keys (a, s, d, w) my character will jump out of the screen because it's going to fast.

    My question: How can I make the code so my character will move when I hold down one of the movement buttons(a, s, w, d), but without that the character is going so fast that it's jumping out of the screen?

    here is my movement sub:
    Code:
        Private Sub frmMain_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    
            'MOVEMENT'
            If e.KeyCode = Keys.A Then
                If P(MyIndex).Dir = DIR_LEFT Then
                    P(MyIndex).X = P(MyIndex).X - 1
                Else
                    P(MyIndex).Dir = DIR_LEFT
                End If
            End If
    
                If e.KeyCode = Keys.D Then
                    If P(MyIndex).Dir = DIR_RIGHT Then
                        P(MyIndex).X = P(MyIndex).X + 1
                    Else
                        P(MyIndex).Dir = DIR_RIGHT
                    End If
                End If
    
                If e.KeyCode = Keys.S Then
                    If P(MyIndex).Dir = DIR_DOWN Then
                        P(MyIndex).Y = P(MyIndex).Y + 1
                    Else
                        P(MyIndex).Dir = DIR_DOWN
                    End If
                End If
    
                If e.KeyCode = Keys.W Then
                    If P(MyIndex).Dir = DIR_UP Then
                        P(MyIndex).Y = P(MyIndex).Y - 1
                    Else
                        P(MyIndex).Dir = DIR_UP
                    End If
                End If
    
        End Sub

  2. #2
    Hyperactive Member Aash's Avatar
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    491

    Re: making a character move

    here's .paul. 's post in it..
    http://www.vbforums.com/showthread.php?t=660450

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2011
    Posts
    118

    Re: making a character move

    Quote Originally Posted by Aash View Post
    noonoo im sorry, that's not what I ment. I've already got that, but now I want my walking character walk not so fast

    look at the video for what I mean (got to upload it via mediafire because its 11MB) http://download790.mediafire.com/n5p...9e/example.avi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width