How to display a sprite
This sample program shows you how to display and animate a sprite using the bitblt function of the Windows API.
Download the complete sprite player example.

I am using a timer control to do the task of displaying and animating the sprite. You could also use a "do while..." loop to do so.

---code begins here---

Private Sub Timer1_Timer()
Static stat As Integer
stat = stat + 1
If stat >= max_img Then stat = 0
rc = BitBlt(Picture1.hdc, 0, 0, sprietwidth, spriteheight, Form1.storage.hdc, spritwidth * stat, 0, SRCCOPY)
End Sub

---code ends here---

Comments:
Variables: stat : stores the number of the currently displayed frame
max_img : number of frames
picture1.hdc : picture1 is the control in which the sprite is being displayed
SRCCOPY = &HCC0020 'flags for the BitBlt function
BitBlt function
usage: returncode = BitBlt(destination control, destx, desty, spritewidth, spriteheight, source control, source x, source y, flags)
Go back to my vb-page