Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sprites issue.
#1
Okay, 32x64 Sprites are what I was using. I am switching to 64x64, yet keeping the same 32x64 sprite, just centering it. This allows me have larger ingame items(Wings, Weapons, Etc.).

I finished the 64x64. Although now the player is centered in between two tiles when Blted. I need players to be on one tile, With pixels overlapping the tiles on the sides.

Heres an image showing how it is, and how it needs to be..
[Image: spritesnh5.png]

If you have an idea on just how I can do this, It'd be highly appreciated if you would reply.
Reply
#2
its just some simple offsetting in the bltsprite code. Post your bltPlayer code, and ill fix it and send it back.
Reply
#3
It's not a normal BltPlayer code.. There's a lot of sprites per sheet, 36... Although here you go.

Code:
Sub BltPlayer(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
               Anim = 0
               If (Player(Index).yOffset < PIC_Y / 3) Then
               Anim = 0
               ElseIf (Player(Index).yOffset > PIC_Y / 3) And ((Player(Index).yOffset > PIC_Y / 3 * 2)) Then
               Anim = 1
               ElseIf (Player(Index).yOffset > PIC_Y / 3) And ((Player(Index).yOffset > PIC_Y / 3 * 1)) Then
               Anim = 2
               End If
               If Player(Index).Sitting = 1 Then
                Anim = 8
               End If
           Case DIR_DOWN
               Anim = 0
               If (Player(Index).yOffset < PIC_X / 6 * -1) Then Anim = 1
               If (Player(Index).yOffset < PIC_X / 4 * -1) Then Anim = 2
               If Player(Index).Sitting = 1 Then
                Anim = 8
               End If
           Case DIR_LEFT
               Anim = 0
               If (Player(Index).xOffset < PIC_Y / 3) Then
               Anim = 0
               ElseIf (Player(Index).xOffset > PIC_Y / 3) And ((Player(Index).xOffset > PIC_Y / 3 * 4)) Then
               Anim = 4
               ElseIf (Player(Index).xOffset > PIC_Y / 3) And ((Player(Index).xOffset > PIC_Y / 3 * 3)) Then
               Anim = 3
                ElseIf (Player(Index).xOffset > PIC_Y / 3) And ((Player(Index).xOffset > PIC_Y / 3 * 2)) Then
               Anim = 2
                ElseIf (Player(Index).xOffset > PIC_Y / 3) And ((Player(Index).xOffset > PIC_Y / 3 * 1)) Then
               Anim = 1
               End If
               If Player(Index).Sitting = 1 Then
                Anim = 8
               End If
           Case DIR_RIGHT
               Anim = 0
               If (Player(Index).xOffset < PIC_Y / 5 * -1) Then Anim = 4
               If (Player(Index).xOffset < PIC_Y / 4 * -1) Then Anim = 3
               If (Player(Index).xOffset < PIC_Y / 3 * -1) Then Anim = 2
               If (Player(Index).xOffset < PIC_Y / 2 * -1) Then Anim = 1
               If Player(Index).Sitting = 1 Then
                Anim = 8
               End If
       End Select
   Else
       If Player(Index).AttackTimer + 500 > GetTickCount Then
           Anim = 6
        If Player(Index).AttackTimer + 400 > GetTickCount Then
           Anim = 5
       End If
   End If
   End If
    
    ' Check to see if we want to stop making him attack
    If Player(Index).AttackTimer + 1000 < GetTickCount Then
        Player(Index).Attacking = 0
        Player(Index).AttackTimer = 0
    End If
    
    rec.Top = GetPlayerSprite(Index) * 64 + 32
    rec.Bottom = rec.Top + 32
    rec.Left = (GetPlayerDir(Index) * 9 + Anim) * 64
    rec.Right = rec.Left + 64
    
    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
        rec.Top = rec.Top + (y * -1)
    End If
        
    rec.Top = GetPlayerSprite(Index) * PIC_Y + PIC_Y
    rec.Bottom = rec.Top + PIC_Y
        
    Call DD_BackBuffer.BltFast(x, y, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
    
End Sub
Reply
#4
Mess with this

x = GetPlayerX(Index) * PIC_X + Player(Index).xOffset - 32
y = GetPlayerY(Index) * PIC_Y + Player(Index).yOffset
Reply
#5
TonyNooblet Wrote:Mess with this

x = GetPlayerX(Index) * PIC_X + Player(Index).xOffset - 32
y = GetPlayerY(Index) * PIC_Y + Player(Index).yOffset

Worked perfect! I owe you one, Thanks a lot.
Reply
#6
wisefire Wrote:
TonyNooblet Wrote:Mess with this

x = GetPlayerX(Index) * PIC_X + Player(Index).xOffset - 32
y = GetPlayerY(Index) * PIC_Y + Player(Index).yOffset

Worked perfect! I owe you one, Thanks a lot.

can you tell me what you did
i wanted to know this too
Reply
#7
doomteam1 Wrote:can you tell me what you did
i wanted to know this too

In BltPlayer I changed
Code:
x = GetPlayerX(Index) * PIC_X + Player(Index).xOffset
y = GetPlayerY(Index) * PIC_Y + Player(Index).yOffset - 4
to
Code:
x = GetPlayerX(Index) * PIC_X + Player(Index).xOffset - 16
y = GetPlayerY(Index) * PIC_Y + Player(Index).yOffset

and

Code:
rec.Top = GetPlayerSprite(Index)
    rec.Bottom = rec.Top
    rec.Left = (GetPlayerDir(Index) * 9 + Anim)
    rec.Right = rec.Left
to
Code:
rec.Top = GetPlayerSprite(Index) * 64 + 32
    rec.Bottom = rec.Top + 32
    rec.Left = (GetPlayerDir(Index) * 9 + Anim) * 64
    rec.Right = rec.Left + 64
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)