This is what I have, and it works fine:
Code:
Public Sub BltNpcTop(ByVal MapNpcNum As Long)
Dim Anim As Byte
Dim X As Long, y As Long
' Make sure that theres an npc there, and if not exit the sub
If MapNpc(MapNpcNum).num <= 0 Then
Exit Sub
End If
' Only used if ever want to switch to blt rather then bltfast
With rec_pos
.top = MapNpc(MapNpcNum).y * PIC_Y + MapNpc(MapNpcNum).YOffset
.Bottom = .top + PIC_Y
.Left = MapNpc(MapNpcNum).X * PIC_X + MapNpc(MapNpcNum).XOffset
.Right = .Left + PIC_X
End With
' Check for animation
Anim = 0
If MapNpc(MapNpcNum).Attacking = 0 Then
Select Case MapNpc(MapNpcNum).Dir
Case DIR_UP
If (MapNpc(MapNpcNum).YOffset < PIC_Y / 2) Then Anim = 1
Case DIR_DOWN
If (MapNpc(MapNpcNum).YOffset < PIC_Y / 2 * -1) Then Anim = 1
Case DIR_LEFT
If (MapNpc(MapNpcNum).XOffset < PIC_Y / 2) Then Anim = 1
Case DIR_RIGHT
If (MapNpc(MapNpcNum).XOffset < PIC_Y / 2 * -1) Then Anim = 1
End Select
Else
If MapNpc(MapNpcNum).AttackTimer + 500 > GetTickCount Then
Anim = 2
End If
End If
' Check to see if we want to stop making him attack
With MapNpc(MapNpcNum)
If .AttackTimer + 1000 < GetTickCount Then
.Attacking = 0
.AttackTimer = 0
End If
End With
With rec
.top = Npc(MapNpc(MapNpcNum).num).Sprite * PIC_Y
.Bottom = .top + PIC_Y
.Left = (MapNpc(MapNpcNum).Dir * 3 + Anim) * PIC_X
.Right = .Left + PIC_X
End With
With MapNpc(MapNpcNum)
X = .X * PIC_X + .XOffset
y = .y * PIC_Y + .YOffset ' - 4 BJORN
End With
' 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 - ESIZE_YTOP, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub