bltPlayer & bltPlayerTop - William - 23-09-2006
Im in need of some help, I can't seem to get a thing working. You see, when my player walks to the very top of the map, halv of him dissapears, I believe many have had the same problem. And the same goes when he walks to the very left, but only certain equipment dissapears then.
bltPlayer
Code: Sub BltPlayer(ByVal Index As Long)
Dim Anim As Byte
Dim X As Long, Y As Long
Dim AttackSpeed As Long
If GetPlayerWeaponSlot(Index) > 0 Then
AttackSpeed = Item(GetPlayerInvItemNum(Index, GetPlayerWeaponSlot(Index))).AttackSpeed
Else
AttackSpeed = 1000
End If
' 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
If Player(Index).Attacking = 0 Then
Select Case GetPlayerDir(Index)
Case DIR_UP
If (Player(Index).YOffset < PIC_Y / 1) Then
Anim = 1
End If
If (Player(Index).YOffset < PIC_Y / 2) Then
Anim = 2
End If
If (Player(Index).YOffset < PIC_Y / 8) Then
Anim = 0
End If
Case DIR_DOWN
If (Player(Index).YOffset > (PIC_Y / 1) * -1) Then
Anim = 1
End If
If (Player(Index).YOffset > (PIC_Y / 2) * -1) Then
Anim = 2
End If
If (Player(Index).YOffset > (PIC_Y / 8) * -1) Then
Anim = 0
End If
Case DIR_LEFT
If (Player(Index).XOffset < PIC_Y / 1) Then
Anim = 1
End If
If (Player(Index).XOffset < PIC_Y / 2) Then
Anim = 0
End If
Case DIR_RIGHT
If (Player(Index).XOffset < PIC_Y / 2 * -1) Then
Anim = 1
End If
End Select
Else
If Player(Index).AttackTimer + AttackSpeed > GetTickCount Then
Anim = 3
End If
End If
' Check to see if we want to stop making him attack
If Player(Index).AttackTimer + AttackSpeed < GetTickCount Then
Player(Index).Attacking = 0
Player(Index).AttackTimer = 0
End If
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
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
If GetPlayerDir(Index) = DIR_DOWN Then
If Player(Index).Wing > 0 Then
If GetPlayerAccess(Index) < 1 Then
rec.top = 170 * PIC_Y + 32
ElseIf GetPlayerAccess(Index) > 0 Then
rec.top = 172 * PIC_Y + 32
End If
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * 64
rec.Right = rec.Left + PIC_X + 32
Call DD_BackBuffer.BltFast(X - 16, Y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
If Player(Index).Cape > 0 Then
rec.top = Item(Player(Index).Cape).Pic * PIC_Y + 32
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
Call DD_BackBuffer.BltFast(X, Y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
If GetPlayerDir(Index) = DIR_UP Then
If Player(Index).Shield > 0 Then
rec.top = Item(Player(Index).Shield).Pic * PIC_Y + 32
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
Call DD_BackBuffer.BltFast(X, Y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
'If Item(Player(Index).Weapon).Pic 0 Then
rec.top = Item(Player(Index).Weapon).Pic * PIC_Y + 32
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * 64
rec.Right = rec.Left + PIC_X + 32
Call DD_BackBuffer.BltFast(X - 16, Y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
If GetPlayerDir(Index) = DIR_DOWN Then
If Player(Index).Weapon > 0 Then
rec.top = Item(Player(Index).Weapon).Pic * PIC_Y + 32
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * 64
rec.Right = rec.Left + PIC_X + 32
Call DD_BackBuffer.BltFast(X - 16, Y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
If Player(Index).Shield > 0 Then
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
rec.top = Item(Player(Index).Shield).Pic * PIC_Y + 32
rec.Bottom = rec.top + PIC_Y
Call DD_BackBuffer.BltFast(X, Y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
If GetPlayerDir(Index) = DIR_UP Then
If Player(Index).Cape > 0 Then
rec.top = Item(Player(Index).Cape).Pic * PIC_Y + 32
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
Call DD_BackBuffer.BltFast(X, Y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
If Player(Index).Wing > 0 Then
If GetPlayerAccess(Index) < 1 Then
rec.top = 170 * PIC_Y + 32
ElseIf GetPlayerAccess(Index) > 0 Then
rec.top = 172 * PIC_Y + 32
End If
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * 64
rec.Right = rec.Left + PIC_X + 32
Call DD_BackBuffer.BltFast(X - 16, Y, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
End Sub
bltPlayerTop
Code: Public Sub BltPlayerTop(ByVal Index As Long)
Dim Anim As Byte
Dim X As Long, Y As Long
Dim AttackSpeed As Long
If GetPlayerWeaponSlot(Index) > 0 Then
AttackSpeed = Item(GetPlayerInvItemNum(Index, GetPlayerWeaponSlot(Index))).AttackSpeed
Else
AttackSpeed = 1000
End If
' 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
If Player(Index).Attacking = 0 Then
Select Case GetPlayerDir(Index)
Case DIR_UP
If (Player(Index).YOffset < PIC_Y / 1) Then
Anim = 1
End If
If (Player(Index).YOffset < PIC_Y / 2) Then
Anim = 2
End If
If (Player(Index).YOffset < PIC_Y / 8) Then
Anim = 0
End If
Case DIR_DOWN
If (Player(Index).YOffset > (PIC_Y / 1) * -1) Then
Anim = 1
End If
If (Player(Index).YOffset > (PIC_Y / 2) * -1) Then
Anim = 2
End If
If (Player(Index).YOffset > (PIC_Y / 8) * -1) Then
Anim = 0
End If
Case DIR_LEFT
If (Player(Index).XOffset < PIC_Y / 1) Then
Anim = 1
End If
If (Player(Index).XOffset < PIC_Y / 2) Then
Anim = 0
End If
Case DIR_RIGHT
If (Player(Index).XOffset < PIC_Y / 2 * -1) Then
Anim = 1
End If
End Select
Else
If Player(Index).AttackTimer + AttackSpeed > GetTickCount Then
Anim = 3
End If
End If
' Check to see if we want to stop making him attack
If Player(Index).AttackTimer + AttackSpeed < GetTickCount Then
Player(Index).Attacking = 0
Player(Index).AttackTimer = 0
End If
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
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
If GetPlayerDir(Index) = DIR_DOWN Then
If Player(Index).Wing > 0 Then
If GetPlayerAccess(Index) < 1 Then
rec.top = 170 * PIC_Y
ElseIf GetPlayerAccess(Index) > 0 Then
rec.top = 172 * PIC_Y
End If
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * 64
rec.Right = rec.Left + PIC_X + 32
Call DD_BackBuffer.BltFast(X - 16, Y - 32, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
If Player(Index).Cape > 0 Then
rec.top = Item(Player(Index).Cape).Pic * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
Call DD_BackBuffer.BltFast(X, Y - 32, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
If GetPlayerDir(Index) = DIR_UP Then
If Player(Index).Shield > 0 Then
rec.top = Item(Player(Index).Shield).Pic * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
Call DD_BackBuffer.BltFast(X, Y - 32, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
'If Item(Player(Index).Weapon).Pic 0 Then
rec.top = Item(Player(Index).Cape).Pic * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
Call DD_BackBuffer.BltFast(X, Y - 32, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
If Player(Index).Wing > 0 Then
If GetPlayerAccess(Index) < 1 Then
rec.top = 170 * PIC_Y
ElseIf GetPlayerAccess(Index) > 0 Then
rec.top = 172 * PIC_Y
End If
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * 64
rec.Right = rec.Left + PIC_X + 32
Call DD_BackBuffer.BltFast(X - 16, Y - 32, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
If Player(Index).Armor > 0 Then
rec.top = Item(Player(Index).Armor).Pic * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
Call DD_BackBuffer.BltFast(X, Y - 32, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
'ElseIf Player(Index).Armor 0 Then
rec.top = Item(Player(Index).Helmet).Pic * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
Call DD_BackBuffer.BltFast(X, Y - 37, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
ElseIf Player(Index).Helmet 0 Then
rec.top = Item(Player(Index).Shield).Pic * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
Call DD_BackBuffer.BltFast(X, Y - 32, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
If GetPlayerDir(Index) = DIR_RIGHT Then
If Player(Index).Weapon > 0 Then
rec.top = Item(Player(Index).Weapon).Pic * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * 64
rec.Right = rec.Left + PIC_X + 32
Call DD_BackBuffer.BltFast(X - 16, Y - 32, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
If GetPlayerDir(Index) = DIR_DOWN Then
If Player(Index).Weapon > 0 Then
rec.top = Item(Player(Index).Weapon).Pic * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * 64
rec.Right = rec.Left + PIC_X + 32
Call DD_BackBuffer.BltFast(X - 16, Y - 32, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
If Player(Index).Shield > 0 Then
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
rec.top = Item(Player(Index).Shield).Pic * PIC_Y
rec.Bottom = rec.top + PIC_Y
Call DD_BackBuffer.BltFast(X, Y - 32, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
If GetPlayerDir(Index) = DIR_UP Then
If Player(Index).Cape > 0 Then
rec.top = Item(Player(Index).Cape).Pic * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * PIC_X
rec.Right = rec.Left + PIC_X
Call DD_BackBuffer.BltFast(X, Y - 32, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
If Player(Index).Wing > 0 Then
If GetPlayerAccess(Index) < 1 Then
rec.top = 170 * PIC_Y
ElseIf GetPlayerAccess(Index) > 0 Then
rec.top = 172 * PIC_Y
End If
rec.Bottom = rec.top + PIC_Y
rec.Left = (GetPlayerDir(Index) * 4 + Anim) * 64
rec.Right = rec.Left + PIC_X + 32
Call DD_BackBuffer.BltFast(X - 16, Y - 32, DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
End Sub
I hope you can help me out 
By the way, im like 100% sure it has to do with this:
Code: ' 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
- Misunderstood - 23-09-2006
ugh I hate how ms has that bug in it, though with ms it isnt a bug since it never gets called, when people add 32x64 it turns into a bug
Code: ' 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
you set y to 0. So the next line is just setting .top to .top because 0*-1 is 0. FUCKIN ZERO....GAHHHHH. (it angers me )
so put the y after the with...
There might be other problems, but start with that
- pingu - 23-09-2006
I made an old tutorial for Elysium on how to fix that "bug" you get when you get near the top. It's what you are looking for, but you'll have to extract the information you need from it.
http://www.splamm.com/elysium/forums/vi ... .php?t=704
Yeah, the subs that I coded for Elysium work all the time when your player goes above the screen for any size. I'm not sure about the sides when it is greater than 32, though.
- William - 23-09-2006
@Misunderstood: It didn't do any difference, here is what it looks like:
![[Image: errorgs0.png]](http://img207.imageshack.us/img207/1045/errorgs0.png)
And here is the new code:
Code: If Y < 0 Then
With rec
.top = .top + (Y * -1)
End With
Y = 0
End If
@Pingu: So your saying that I should use this:
Code: x = GetPlayerX(Index) * PIC_X + sx + Player(Index).XOffset
y = GetPlayerY(Index) * PIC_Y - PIC_Y + sx + Player(Index).YOffset
If y < 0 Then
y = 0
If GetPlayerDir(Index) = DIR_DOWN And Player(Index).Moving > 0 Then
rec.Top = rec.Top - Player(Index).YOffset
Else
rec.Top = rec.Top - Player(Index).YOffset + PIC_Y
End If
End If
- pingu - 23-09-2006
William Wrote:@Pingu: So your saying that I should use this:
Code: x = GetPlayerX(Index) * PIC_X + sx + Player(Index).XOffset
y = GetPlayerY(Index) * PIC_Y - PIC_Y + sx + Player(Index).YOffset
If y < 0 Then
y = 0
If GetPlayerDir(Index) = DIR_DOWN And Player(Index).Moving > 0 Then
rec.Top = rec.Top - Player(Index).YOffset
Else
rec.Top = rec.Top - Player(Index).YOffset + PIC_Y
End If
End If
Trying wouldn't hurt. Just do it for the sprite only first and then make it work with the items later. I'm assuming you have scrolling going and it uses the same variables to work.
- William - 23-09-2006
I dont really have scrolling atm, well I have it, but I just grabbed some wierd tut and it has a bug.. Since I cant find a bug free =/
Well anyhow.. let me test it now... hmm, works pretty well. Thank you. Now I check the x too, might work fine
- Misunderstood - 23-09-2006
my 32x64 tut for MS works
- William - 23-09-2006
Misunderstood Wrote:my 32x64 tut for MS works 
Well, my works to now So mission Closed. Thanks guys
- Dragoons Master - 23-09-2006
I have 64X64 npc on my game and I had the same problem. I solved it on a much easiest way. Instead of bliting top and bottom, why just blit on the right order? That's my code(you dont need to change anything on your BltNpc sub):
Code: For Y = 0 To MAX_MAPY
For i = 1 To MAX_MAP_NPCS
If MapNpc(i).Y = Y Then
Call BltNpc(i)
End If
Next i
Next Y
- Misunderstood - 24-09-2006
I don't get what your saying DM, and if I do, it wont work and your way is slow, looping through so many extra times. It just seems like a waste to me.
- Kenko - 24-09-2006
Because, if the player is big enough, his head will be under the npc.
- pingu - 24-09-2006
Yeah, blitting the head needs to be in it's own loop because otherwise people could walk on top of other's heads.
- Dragoons Master - 24-09-2006
Misunderstood Wrote:I don't get what your saying DM, and if I do, it wont work and your way is slow, looping through so many extra times. It just seems like a waste to me. It works and works perfectly. Sure it does loop a few times but its not slow at all, player dont notice it doesn't slowed my fps even 1 point... I'm already using it on my game for a while.
|