Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
About Player Sprites
#1
Ok I am writting a 96*96 player sprite code, and I can get it to work with the acception of I can't get it to blt the second class correctly. and by that I mean when you create the character, it loads 1/3 of the actual sprite you want it to, and 1/2 of the other class, any idea how to fix this? if need be I'll post the code.

Thank you in advance,
- Korrey D.
Reply
#2
In the bitblt part, there are a place for how big picture you want to blit, it's probably typed as PIC_X and PIC_Y. So try adding + 64 on both of them.
Reply
#3
here's the whole bltPlayer sub for MSE(Could you please highlight which thing?)

Code:
Public Sub BltPlayer(ByVal Index As Long)
'****************************************************************
'* WHEN        WHO        WHAT
'* ----        ---        ----
'* 07/12/2005  Shannara   Optimized function.
'****************************************************************

Dim Anim As Byte
Dim x As Long, y As Long

    ' Only used if ever want to switch to blt rather then bltfast
    With rec_pos
        .top = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset
        .Bottom = .top + PIC_Y
        .Left = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
        .Right = .Left + PIC_X
    End With
    
    ' Check for animation
    Anim = 0
    If Player(Index).Attacking = 0 Then
        Select Case GetPlayerDir(Index)
            Case DIR_UP
                If (Player(Index).YOffset < PIC_Y / 2) Then Anim = 1
            Case DIR_DOWN
                If (Player(Index).YOffset < PIC_Y / 2 * -1) Then Anim = 1
            Case DIR_LEFT
                If (Player(Index).XOffset < PIC_Y / 2) Then Anim = 1
            Case DIR_RIGHT
                If (Player(Index).XOffset < PIC_Y / 2 * -1) Then Anim = 1
        End Select
    Else
        If Player(Index).AttackTimer + 500 > GetTickCount Then
            Anim = 2
        End If
    End If
    
    ' Check to see if we want to stop making him attack
    With Player(Index)
        If .AttackTimer + 1000 < GetTickCount Then
            .Attacking = 0
            .AttackTimer = 0
        End If
    End With
    
    With rec
        .top = GetPlayerSprite(Index) * PIC_Y
        .Bottom = .top + PIC_Y
        .Left = (GetPlayerDir(Index) * 3 + Anim) * PIC_X
        .Right = .Left + PIC_X
    End With
    
    x = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
    y = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset - 4
    
    ' Check if its out of bounds because of the offset
    If y < 0 Then
        y = 0
        With rec
            .top = .top + (y * -1)
        End With
    End If
        
    Call DD_BackBuffer.BltFast(x, y, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub
Reply
#4
I though you had trouble blitting the char on character selection =/

Well anyway. If your gonna use 96*96 sprites. You need to have more than just one sub to handle the player.

You'll need 2 subs for it, bltPlayer and bltPlayerTop. Do you have bltPlayerTop as it is now? If so, please post that too.
Reply
#5
Ok here's everything I have made for blting the player
(This is my one for 32*64.)
Code:
' Blit out players
        For i = 1 To MAX_PLAYERS
            If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
                Call BltPlayer(i)
                Call BltPlayerMid(i)
            End If
        Next i

Public Sub BltPlayer(ByVal Index As Long)
'****************************************************************
'* WHEN        WHO        WHAT
'* ----        ---        ----
'* 07/12/2005  Shannara   Optimized function.
'****************************************************************

Dim anim As Byte
Dim x As Long, y As Long

    ' Only used if ever want to switch to blt rather then bltfast
    With rec_pos
        .top = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset
        .Bottom = .top + PIC_Y
        .Left = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
        .Right = .Left + PIC_X
    End With
    
    ' Check for animation
    anim = 0
    If Player(Index).Attacking = 0 Then
        Select Case GetPlayerDir(Index)
            Case DIR_UP
                If (Player(Index).YOffset < PIC_Y / 2) Then anim = 1
            Case DIR_DOWN
                If (Player(Index).YOffset < PIC_Y / 2 * -1) Then anim = 1
            Case DIR_LEFT
                If (Player(Index).XOffset < PIC_Y / 2) Then anim = 1
            Case DIR_RIGHT
                If (Player(Index).XOffset < PIC_Y / 2 * -1) Then anim = 1
        End Select
    Else
        If Player(Index).AttackTimer + 500 > GetTickCount Then
            anim = 2
        End If
    End If
    
    ' Check to see if we want to stop making him attack
    With Player(Index)
        If .AttackTimer + 1000 < GetTickCount Then
            .Attacking = 0
            .AttackTimer = 0
        End If
    End With
    
    With rec
        .top = GetPlayerSprite(Index) * PIC_Y + PIC_Y
        .Bottom = .top + PIC_Y
        .Left = (GetPlayerDir(Index) * 3 + anim) * PIC_X
        .Right = .Left + PIC_X
    End With
    
    x = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
    y = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset - 4
    
    ' Check if its out of bounds because of the offset
    If y < 0 Then
        y = 0
        With rec
            .top = .top + (y * -1)
        End With
    End If
        
    Call DD_BackBuffer.BltFast(x, y, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub

Public Sub BltPlayerTop(ByVal Index As Long)

Dim anim As Byte
Dim x As Long, y As Long

    ' Only used if ever want to switch to blt rather then bltfast
    With rec_pos
        .top = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset
        .Bottom = .top + PIC_Y
        .Left = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
        .Right = .Left + PIC_X
    End With
    
    ' Check for animation
    anim = 0
    If Player(Index).Attacking = 0 Then
        Select Case GetPlayerDir(Index)
            Case DIR_UP
                If (Player(Index).YOffset < PIC_Y / 2) Then anim = 1
            Case DIR_DOWN
                If (Player(Index).YOffset < PIC_Y / 2 * -1) Then anim = 1
            Case DIR_LEFT
                If (Player(Index).XOffset < PIC_Y / 2) Then anim = 1
            Case DIR_RIGHT
                If (Player(Index).XOffset < PIC_Y / 2 * -1) Then anim = 1
        End Select
    Else
        If Player(Index).AttackTimer + 500 > GetTickCount Then
            anim = 2
        End If
    End If
    
    ' Check to see if we want to stop making him attack
    With Player(Index)
        If .AttackTimer + 1000 < GetTickCount Then
            .Attacking = 0
            .AttackTimer = 0
        End If
    End With
    
    With rec
        .top = GetPlayerSprite(Index) * PIC_Y
        .Bottom = .top + PIC_Y
        .Left = (GetPlayerDir(Index) * 3 + anim) * PIC_X
        .Right = .Left + PIC_X
    End With
    
    x = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
    y = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset - 4
    
    ' Check if its out of bounds because of the offse
    y = y - 32
    If y < 0 And y > -32 Then
        y = 0
        With rec
            .top = .top - y
        End With
    End If
        
    Call DD_BackBuffer.BltFast(x, y, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub

Then I have this for 32*96(still trying to even figure out how to make them wider) but my prob is it won't blt the players correctly.

Code:
' Blit out players
        For i = 1 To MAX_PLAYERS
            If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
                Call BltPlayer(i)
            End If
        Next i

  ' Blit out players top
        For i = 1 To MAX_PLAYERS
            If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
                Call BltPlayerTop(i)
            End If
        Next i

Public Sub BltPlayer(ByVal Index As Long)
'****************************************************************
'* WHEN        WHO        WHAT
'* ----        ---        ----
'* 07/12/2005  Shannara   Optimized function.
'****************************************************************

Dim anim As Byte
Dim x As Long, y As Long

    ' Only used if ever want to switch to blt rather then bltfast
    With rec_pos
        .top = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset
        .Bottom = .top + PIC_Y
        .Left = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
        .Right = .Left + PIC_X
    End With
    
    ' Check for animation
    anim = 0
    If Player(Index).Attacking = 0 Then
        Select Case GetPlayerDir(Index)
            Case DIR_UP
                If (Player(Index).YOffset < PIC_Y / 2) Then anim = 1
            Case DIR_DOWN
                If (Player(Index).YOffset < PIC_Y / 2 * -1) Then anim = 1
            Case DIR_LEFT
                If (Player(Index).XOffset < PIC_Y / 2) Then anim = 1
            Case DIR_RIGHT
                If (Player(Index).XOffset < PIC_Y / 2 * -1) Then anim = 1
        End Select
    Else
        If Player(Index).AttackTimer + 500 > GetTickCount Then
            anim = 2
        End If
    End If
    
    ' Check to see if we want to stop making him attack
    With Player(Index)
        If .AttackTimer + 1000 < GetTickCount Then
            .Attacking = 0
            .AttackTimer = 0
        End If
    End With
    
    With rec
        .top = GetPlayerSprite(Index) * PIC_Y + PIC_Y
        .Bottom = .top + PIC_Y + PIC_Y
        .Left = (GetPlayerDir(Index) * 3 + anim) * PIC_X
        .Right = .Left + PIC_X
    End With
    
    x = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
    y = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset - 4
    
    ' Check if its out of bounds because of the offset
    If y < 0 Then
        y = 0
        With rec
            .top = .top + (y * -1)
        End With
    End If
        
    Call DD_BackBuffer.BltFast(x, y, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub

Public Sub BltPlayerTop(ByVal Index As Long)

Dim anim As Byte
Dim x As Long, y As Long

    ' Only used if ever want to switch to blt rather then bltfast
    With rec_pos
        .top = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset
        .Bottom = .top + PIC_Y
        .Left = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
        .Right = .Left + PIC_X
    End With
    
    ' Check for animation
    anim = 0
    If Player(Index).Attacking = 0 Then
        Select Case GetPlayerDir(Index)
            Case DIR_UP
                If (Player(Index).YOffset < PIC_Y / 2) Then anim = 1
            Case DIR_DOWN
                If (Player(Index).YOffset < PIC_Y / 2 * -1) Then anim = 1
            Case DIR_LEFT
                If (Player(Index).XOffset < PIC_Y / 2) Then anim = 1
            Case DIR_RIGHT
                If (Player(Index).XOffset < PIC_Y / 2 * -1) Then anim = 1
        End Select
    Else
        If Player(Index).AttackTimer + 500 > GetTickCount Then
            anim = 2
        End If
    End If
    
    ' Check to see if we want to stop making him attack
    With Player(Index)
        If .AttackTimer + 1000 < GetTickCount Then
            .Attacking = 0
            .AttackTimer = 0
        End If
    End With
    
    With rec
        .top = GetPlayerSprite(Index) * PIC_Y
        .Bottom = .top + PIC_Y
        .Left = (GetPlayerDir(Index) * 3 + anim) * PIC_X
        .Right = .Left + PIC_X
    End With
    
    x = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
    y = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset - 4
    
    ' Check if its out of bounds because of the offse
    y = y - 64
    If y < 0 And y > -64 Then
        y = 0
        With rec
            .top = .top - y
        End With
    End If
        
    Call DD_BackBuffer.BltFast(x, y, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub
If you look over even slightly you'll notice some small changes, I forget who but someone told me this won't work, it does to the extent that it won't blt the other classes correctly.
Reply
#6
You both do the same misstage. You want your sprite 96*96, the feets on the sprite should be 32*96. The bottom layer of the char.

So for the first 32*96 you should use: bltPlayer sub
For the above body and the head, you should use: bltPlayerTop

No bltPlayerMid is needed, since both the upper parts works the same way, they should both go above a enemy, if you stand below one. And should both get under a fringe tile etc..

So you need 2 subs, not 3. And the part to change is these:
Code:
With rec
        .top = GetPlayerSprite(Index) * PIC_Y + PIC_Y
        .Bottom = .top + PIC_Y + PIC_Y
        .Left = (GetPlayerDir(Index) * 3 + anim) * PIC_X
        .Right = .Left + PIC_X
    End With
That you need to adjust so it blits 32*96 and 64*96. And also remember to change the:
Code:
Call DD_BackBuffer.BltFast(x, y, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
So make sure that line blits it above the feet layer (the first 32*96). Make y to y-64. I think that should work fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)