Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Blting Errors... Help?
#1
So I've not gotten into blting stuff too much. I managed to make a pretty good paperdoll system from scratch and so far it's gone okay, except this one thing... lol

When you are on the first tile of the map, as in Y=0, helmet's don't seem to work out :roll:. I'm not even sure it can be fixed but here's some screenshot's to demonstrate:

Good Helmet:
[spoiler][Image: goodry4.png][/spoiler]

Bad helmet:
[spoiler][Image: wtfrn2.png][/spoiler]

And here's the code for blt'ing the helmets/tops of players:

Code:
Public Sub BltPlayerTop(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
    Y = Y - 32
    If Y < 0 And Y > -32 Then
        With rec
              .top = .top - Y
              Y = 0
        End With
    End If
        
    Call DD_BackBuffer.BltFast(X, Y, DD_PlayerSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub

Code:
Public Sub BltHelmet(ByVal index As Long)
Dim Anim As Byte
Dim X As Long, Y As Long
Dim F As Long
Dim BltF As Long

    If GetPlayerHelmetSlot(index)  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 = BltF * PIC_Y
        .Bottom = .top + PIC_Y * 2
        .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) - 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

    If Y < 0 And Y > -32 Then
        With rec
              .top = .top - Y
              Y = 0
        End With
    End If
        
    Call DD_BackBuffer.BltFast(X, Y, DD_PDollSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub

I'm also having some trouble with the names. I have finally created a way that names are always drawn in the exact center of the sprites, so everything looks nice and neat. However, for some reason, there is always one name (maybe the first one to blt) that is off center, and I can't figure out why. It happens with both player's, and npc's.

I use two seperate subs to blt the names for players and npc's but that seems to be irrelevant here. If I warp to a map with no npcs my players name is off center. If I add one npc, it's name is off center and the player name becomes centered. If another player enters the map, it's the same thing. The other players name will show off centered, but my player's name will be centered. It's kind odd.... here's a screenshot of that phenomena as well, and the code:

[spoiler][Image: namesmu1.png][/spoiler]
Code:
Sub BltPlayerName(ByVal index As Long)
Dim TextX As Long, a As Long, b As Long, C As Long, d As Long
Dim TextY As Long
Dim Color As Long, Color2 As Long
    
    ' Check access level
    If GetPlayerPK(index) = NO Then
        Select Case GetPlayerAccess(index)
            Case 0
                Color = QBColor(White)
            Case 1
                Color = QBColor(Pink)
            Case 2
                Color = QBColor(BrightCyan)
            Case 3
                Color = QBColor(Yellow)
            Case 4
                Color = QBColor(BrightGreen)
        End Select
    Else
        Color = QBColor(BrightRed)
    End If
    
    TextX = (GetPlayerX(index) * PIC_X + Player(index).XOffset) - ((getSize(TexthDC, Trim(GetPlayerName(index))).width - 32) / 2)
    TextY = GetPlayerY(index) * PIC_Y + Player(index).YOffset - Int(PIC_Y / 2) - 20
    
    Call DrawText(TexthDC, TextX, TextY, GetPlayerName(index), Color)
End Sub

Code:
Sub BltNpcName(ByVal index As Long)
Dim TextX As Long, TextY As Long, Color As Long, NpcNum As Long

    NpcNum = MapNpc(index).Num
    
    If NpcNum = 0 Then Exit Sub
    
    Color = QBColor(Yellow)
    
    If Npc(MapNpc(index).Num).Level > GetPlayerLevel(MyIndex) + 10 Then
        Color = QBColor(BrightRed)
    ElseIf Npc(MapNpc(index).Num).Level < GetPlayerLevel(MyIndex) - 10 Then
        Color = QBColor(BrightGreen)
    End If
    
    ' Draw name
    TextX = ((MapNpc(index).X * PIC_X) + MapNpc(index).XOffset) - ((getSize(TexthDC, Trim(Npc(NpcNum).Name)).width - 32) / 2)
    
    If Npc(MapNpc(index).Num).Size = SIZE_BIG Then
        TextY = MapNpc(index).Y * PIC_Y + MapNpc(index).YOffset - Int(PIC_Y / 2) - 16
    Else
        TextY = MapNpc(index).Y * PIC_Y + MapNpc(index).YOffset - Int(PIC_Y / 2) - 4
    End If
    
    If Npc(MapNpc(index).Num).Behavior = NPC_BEHAVIOR_QUEST _
        Or Npc(MapNpc(index).Num).Behavior = NPC_BEHAVIOR_SHOPKEEPER _
        Or Npc(MapNpc(index).Num).Behavior = NPC_BEHAVIOR_BANKER _
        Or Npc(MapNpc(index).Num).Behavior = NPC_BEHAVIOR_GAMBLER Then
        Call DrawText(TexthDC, TextX, TextY, Trim(Npc(NpcNum).Name), QBColor(BrightCyan))
    Else
        Call DrawText(TexthDC, TextX, TextY, Trim(Npc(NpcNum).Name), Color)
    End If
End Sub

Any thoughts or ideas would help!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)