02-12-2007, 04:10 AM
Thanks, I figured out the rest form there. Basically, I have it set so that if we are not browsing through the classes, then the sprite will animate. But, it takes about a second to load once we start the form and every time we change sprites, there is slight delay. Any tips on improving the code I use to animate?
Code:
Option Explicit
Public canUpdate As Byte
Private Sub cmbClass_Click()
lblHP.Caption = STR(Class(cmbClass.ListIndex).HP)
lblMP.Caption = STR(Class(cmbClass.ListIndex).MP)
lblSP.Caption = STR(Class(cmbClass.ListIndex).SP)
lblSTR.Caption = STR(Class(cmbClass.ListIndex).STR)
lblDEF.Caption = STR(Class(cmbClass.ListIndex).DEF)
lblSPEED.Caption = STR(Class(cmbClass.ListIndex).SPEED)
lblMAGI.Caption = STR(Class(cmbClass.ListIndex).MAGI)
canUpdate = 0
End Sub
Private Sub cmbClass_Scroll()
canUpdate = 1
End Sub
Private Sub Form_Load()
picSprites.Picture = LoadPicture(App.Path & GFX_PATH & "\sprites" & GFX_EXT)
canUpdate = 1
End Sub
Private Sub timNew_Timer()
'If we are scrolling, update the sprite box
If canUpdate = 0 Then Exit Sub
Call BitBlt(picPic.hdc, 0, 0, PIC_X, PIC_Y, picSprites.hdc, PIC_X * 3, Int(Class(cmbClass.ListIndex).Sprite) * PIC_Y, SRCCOPY)
End Sub
Private Sub timUpdate_Timer()
'If we are set on a class, then update
If canUpdate = 1 Then Exit Sub
Static nxtAnim As Byte
Select Case nxtAnim
Case 0
Call BitBlt(picPic.hdc, 0, 0, PIC_X, PIC_Y, picSprites.hdc, PIC_X * 4, Int(Class(cmbClass.ListIndex).Sprite) * PIC_Y, SRCCOPY)
nxtAnim = 1
Case 1
Call BitBlt(picPic.hdc, 0, 0, PIC_X, PIC_Y, picSprites.hdc, PIC_X * 3, Int(Class(cmbClass.ListIndex).Sprite) * PIC_Y, SRCCOPY)
nxtAnim = 0
End Select
End Sub