TwigX
05-17-2005, 05:05 PM
Im working on a small RPG and its been awhile since Ive worked with VB and I seem to be rusty. Im trying to make an image (IMGSelf) to change its .Picture property between 3 different images on keydown. Harder to explain, but maybe the code can help:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If IMGSelf.Picture = IMGwalk(0).Picture Then
IMGSelf.Picture = IMGwalk(1).Picture
End If
If IMGSelf.Picture = IMGwalk(1).Picture Then
IMGSelf.Picture = IMGwalk(2).Picture
End If
If IMGSelf.Picture = IMGwalk(2).Picture Then
IMGSelf.Picture = IMGwalk(0).Picture
End If
If KeyCode = vbKeyUp Then
IMGSelf.Top = IMGSelf.Top - 435
End If
If KeyCode = vbKeyDown Then
IMGSelf.Top = IMGSelf.Top + 435
End If
If KeyCode = vbKeyLeft Then
IMGSelf.Left = IMGSelf.Left - 300
End If
If KeyCode = vbKeyRight Then
IMGSelf.Left = IMGSelf.Left + 300
End If
End Sub
Private Sub Form_Load()
IMGSelf.Picture = IMGwalk(0).Picture
End Sub
As you can see, Im trying to make it check to see what picture it is using on every keydown, and then rotate to the next one. Heres a screenshot if it helps anything:
http://img283.echo.cx/img283/9774/snap00857sy.jpg
Thanks in advance.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If IMGSelf.Picture = IMGwalk(0).Picture Then
IMGSelf.Picture = IMGwalk(1).Picture
End If
If IMGSelf.Picture = IMGwalk(1).Picture Then
IMGSelf.Picture = IMGwalk(2).Picture
End If
If IMGSelf.Picture = IMGwalk(2).Picture Then
IMGSelf.Picture = IMGwalk(0).Picture
End If
If KeyCode = vbKeyUp Then
IMGSelf.Top = IMGSelf.Top - 435
End If
If KeyCode = vbKeyDown Then
IMGSelf.Top = IMGSelf.Top + 435
End If
If KeyCode = vbKeyLeft Then
IMGSelf.Left = IMGSelf.Left - 300
End If
If KeyCode = vbKeyRight Then
IMGSelf.Left = IMGSelf.Left + 300
End If
End Sub
Private Sub Form_Load()
IMGSelf.Picture = IMGwalk(0).Picture
End Sub
As you can see, Im trying to make it check to see what picture it is using on every keydown, and then rotate to the next one. Heres a screenshot if it helps anything:
http://img283.echo.cx/img283/9774/snap00857sy.jpg
Thanks in advance.