Mirage Source
Help with Displaying Character Sprites - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17)
+---- Thread: Help with Displaying Character Sprites (/showthread.php?tid=1423)



Help with Displaying Character Sprites - Stomach Pulser - 01-12-2007

Hello, I have recently added grimsk8ter11's "Display Sprite At Character Create" tutorial
http://web.miragesource.com/forums/viewtopic.php?f=75&t=32

and I played around with one line of code to display the character facing south. And it works fine. The code I changed was the timer's function to this (I removed the Male and Female If-Then Statement and added the PIC_X * 3 to where a 0 was in the bitBlt.
Code:
Private Sub timNew_Timer()
    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

And, I was trying to display it so that the picture box displayed a character walking loop (i.e. It shows the first frame, second frame, first frame, second frame, etc.) So, I came up with this code:

Code:
Private Sub timNew_Timer()
Dim is Byte
i = 0
    Select Case i
    Case 0
        Call BitBlt(picpic.hdc, 0, 0, PIC_X, PIC_Y, picSprites.hdc, PIC_X * 3, Int(Class(cmbClass.ListIndex).Sprite) * PIC_Y, SRCCOPY)
        i = i + 1
    Case 1
        Call BitBlt(picpic.hdc, 0, 0, PIC_X, PIC_Y, picSprites.hdc, PIC_X * 4, Int(Class(cmbClass.ListIndex).Sprite) * PIC_Y, SRCCOPY)
        i = 0
    End Select
End Sub

But it didn't work, So I played around with the timer interval, making update once every second, but still no luck.

I was wondering if anyone could possibly point me in the right direction (don't just fix it for me, but tell me what is wrong and maybe a hint on how to fix it).

Also, all sprites are 32x32.

Thank you.


Re: Help with Displaying Character Sprites - Stomach Pulser - 02-12-2007

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