1.11MM Members

help with keystrokes to move pic's

 
0
 

i am trying to create a videogame but im having trouble moving a picture.

what im trying to do is move a picture called mario left, right, down, up...
im trying to use the arrow keys...

i dont have much experience either. everytime i press the up key the picture goes randomly to a certain spot. Everytime i press it it goes to the same spot >.>

help me~

Private Sub picmario_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyRight
'this will move mario right
picmario.Move picmario.Left - -50
Case vbKeyLeft
'this will move mario left
picmario.Move picmario.Left - 50
End Select

Select Case KeyCode
Case vbKeyUp
picmario.Move picmario.Top - 50
End Select
End Sub
 
0
 

also the left and right arrow keys work.....but not the up and down...

if possible can u help me doing the keyascii way?

 
0
 

Why two select statements? Where is vbKeyDown? Then, when intellisence comes up for your vbKeyUp, why are you trying to set the left property and not the top property, which if you have read the intellisence is the next arguement...

Good Luck

 
0
 

i dont need help guys i was able to figre it out:D

Question Answered as of 4 Years Ago by vb5prgrmr
 
0
 

i did:

Private Sub picmario_KeyPress(KeyAscii As Integer)
'this will allow the user to use various keys to
'move mario
'this will move the mario up using the 8 key
If KeyAscii = 56 Then
picmario.Top = picmario.Top - 100
End If
'this will move mario down using the 2 key
If KeyAscii = 50 Then
picmario.Top = picmario.Top + 100
End If
'this will move mario left using the 4 key
If KeyAscii = 52 Then
picmario.Left = picmario.Left - 100
End If
'this will move mario right using the 6 key
If KeyAscii = 54 Then
picmario.Left = picmario.Left + 100
End If
End Sub


------
i made it so complex for myself before >,

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: