-
Oct 22nd, 2011, 04:12 AM
#1
Thread Starter
Lively Member
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
-
Oct 22nd, 2011, 05:29 AM
#2
Hyperactive Member
Re: making a character move
-
Oct 22nd, 2011, 09:16 AM
#3
Thread Starter
Lively Member
Re: making a character move
Originally Posted by Aash
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|