QUOTE(Jonathan Malott @ 13 Oct, 2008 - 02:38 PM)

Any idea how to make a bitmap a sprite and then make it move about the screen in even increments?
CODE
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 38 'up arrow
Timer1.Enabled = True
Timer1.Interval = 5
Case 40 'down arrow
Timer2.Enabled = True
Timer2.Interval = 5
Case 39 'right arrow
Timer3.Enabled = True
Timer3.Interval = 5
Case 37 'left arrow
Timer4.Enabled = True
Timer4.Interval = 5
End Select
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 38 'up arrow
Timer1.Enabled = False
Case 40 'down arrow
Timer2.Enabled = False
Case 39 'right arrow
Timer3.Enabled = False
Case 37 'left arrow
Timer4.Enabled = False
End Select
End Sub
Private Sub Timer1_Timer()
Image2.Top = Image2.Top - 20
End Sub
Private Sub Timer2_Timer()
Image2.Top = Image2.Top + 20
End Sub
Private Sub Timer3_Timer()
Image2.Left = Image2.Left + 15
End Sub
Private Sub Timer4_Timer()
Image2.Left = Image2.Left - 20
End Sub
Pretty much i used the cases for the arrow keys in key-down and key-up events and set them to start an alarm with a 5 tick interval on key-down. I made the up/down alarm events 20y/-20y and the left/right alarm events 15x/-15x.
This gives a fairly smooth movement through the form but there is sometimes some flickering and it's more complicated if you want to change the sprites while the picture moves to give it an animated movement look (walking)
hope this helps you.
This post has been edited by W0lfbane: 3 Apr, 2009 - 07:50 PM