Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
64x64 Npcs
#1
woo hoo copy and paste tuts, sorry but im still new and this is all i can really do ill try explain everything as i go along though.
Replace your bltNpc with this:
Code:
Sub BltNpc(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  GetTickCount Then
            Anim = 2
        End If
    End If
    
    ' Check to see if we want to stop making him attack
    If MapNpc(MapNpcNum).AttackTimer + 1000 < GetTickCount Then
        MapNpc(MapNpcNum).Attacking = 0
        MapNpc(MapNpcNum).AttackTimer = 0
    End If
        rec.top = Npc(MapNpc(MapNpcNum).Num).Sprite * 64 + 32
        rec.Bottom = rec.top + 32
        rec.Left = (MapNpc(MapNpcNum).Dir * 3 + Anim) * 64
        rec.Right = rec.Left + 64
    
        X = MapNpc(MapNpcNum).X * 32 + sx - 16 + MapNpc(MapNpcNum).XOffset
        Y = MapNpc(MapNpcNum).Y * 32 + sx + MapNpc(MapNpcNum).YOffset
  
        If Y < 0 Then
            rec.top = Npc(MapNpc(MapNpcNum).Num).Sprite * 64 + 32
            rec.Bottom = rec.top + 32
            Y = MapNpc(MapNpcNum).YOffset + sx
        End If
        
        If X < 0 Then
            rec.Left = (MapNpc(MapNpcNum).Dir * 3 + Anim) * 64 + 16
            rec.Right = rec.Left + 48
            X = MapNpc(MapNpcNum).XOffset + sx
        End If
        
        If X > MAX_MAPX * 32 Then
            rec.Left = (MapNpc(MapNpcNum).Dir * 3 + Anim) * 64
            rec.Right = rec.Left + 48
            X = MAX_MAPX * 32 + sx - 16 + MapNpc(MapNpcNum).XOffset
        End If

        Call DD_BackBuffer.BltFast(X - (NewPlayerX * PIC_X) - NewXOffset, Y - (NewPlayerY * PIC_Y) - NewYOffset, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub

Now, if you dont have 32x64 npcs as it is: Copy the bltNpc and rename it npcTop.
Then replace all the rec.top etc with this
Code:
rec.top = Npc(MapNpc(MapNpcNum).Num).Sprite * PIC_Y
        
     rec.top = Npc(MapNpc(MapNpcNum).Num).Sprite * 64
     rec.Bottom = rec.top + 32
     rec.Left = (MapNpc(MapNpcNum).Dir * 3 + Anim) * 64
     rec.Right = rec.Left + 64

Then under that put
Code:
X = MapNpc(MapNpcNum).X * 32 + sx - 16 + MapNpc(MapNpcNum).XOffset
        Y = MapNpc(MapNpcNum).Y * 32 + sx + MapNpc(MapNpcNum).YOffset
  
        If Y < 0 Then
            rec.top = Npc(MapNpc(MapNpcNum).Num).Sprite * 64 + 32
            rec.Bottom = rec.top + 32
            Y = MapNpc(MapNpcNum).YOffset + sx
        End If
        
        If X < 0 Then
            rec.Left = (MapNpc(MapNpcNum).Dir * 3 + Anim) * 64 + 16
            rec.Right = rec.Left + 48
            X = MapNpc(MapNpcNum).XOffset + sx
        End If
        
        If X > MAX_MAPX * 32 Then
            rec.Left = (MapNpc(MapNpcNum).Dir * 3 + Anim) * 64
            rec.Right = rec.Left + 48
            X = MAX_MAPX * 32 + sx - 16 + MapNpc(MapNpcNum).XOffset
        End If

So the npcTop sub should look like this:
Code:
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  GetTickCount Then
            Anim = 2
        End If
    End If
    
    ' Check to see if we want to stop making him attack
    If MapNpc(MapNpcNum).AttackTimer + 1000 < GetTickCount Then
        MapNpc(MapNpcNum).Attacking = 0
        MapNpc(MapNpcNum).AttackTimer = 0
    End If
    
    rec.top = Npc(MapNpc(MapNpcNum).Num).Sprite * PIC_Y
        
     rec.top = Npc(MapNpc(MapNpcNum).Num).Sprite * 64
     rec.Bottom = rec.top + 32
     rec.Left = (MapNpc(MapNpcNum).Dir * 3 + Anim) * 64
     rec.Right = rec.Left + 64

     X = MapNpc(MapNpcNum).X * 32 + sx - 16 + MapNpc(MapNpcNum).XOffset
     Y = MapNpc(MapNpcNum).Y * 32 + sx - 32 + MapNpc(MapNpcNum).YOffset

     If Y < 0 Then
         rec.top = Npc(MapNpc(MapNpcNum).Num).Sprite * 64 + 32
         rec.Bottom = rec.top
         Y = MapNpc(MapNpcNum).YOffset + sx
     End If
    
     If X < 0 Then
         rec.Left = (MapNpc(MapNpcNum).Dir * 3 + Anim) * 64 + 16
         rec.Right = rec.Left + 48
         X = MapNpc(MapNpcNum).XOffset + sx
     End If
    
     If X > MAX_MAPX * 32 Then
         rec.Left = (MapNpc(MapNpcNum).Dir * 3 + Anim) * 64
         rec.Right = rec.Left + 48
         X = MAX_MAPX * 32 + sx - 16 + MapNpc(MapNpcNum).XOffset
     End If

     Call DD_BackBuffer.BltFast(X - (NewPlayerX * PIC_X) - NewXOffset, Y - (NewPlayerY * PIC_Y) - NewYOffset, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub

Now place this
Code:
' Blit out the npcs top
        For i = 1 To MAX_MAP_NPCS
             Call BltNpcTop(i)
        Next i
Under
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

Now, here is the weird part. For some reason while doing this the sprites when off the surface area. While on the max X they wouldnt blit. Sooo i could have; made the sprites into smaller surfaces such as nptopleft, npctopright etc or just increase the surface.
sooooo comment this out
Code:
'  .lWidth = (MAX_MAPX + 1) * PIC_X
       ' .lHeight = (MAX_MAPY + 1) * PIC_Y
and put this in its spot
Code:
.lWidth = (MAX_MAPX + 1) * PIC_X + 32
        .lHeight = (MAX_MAPY + 1) * PIC_Y + 32

alrighty this should be it all. if i miss anything post here or if theyre are bugs tell me and ill try to help
Reply
#2
This isn't even your code :evil:
Give credits to the owner of the source you ripped
this code from. Learn to how rip also your missing
some things like Public NewPlayerX as Long, etc.

:: Pando
Reply
#3
ok relax, i didnt claim as my own and i dont know who made it. i found it in an old project so chill out
Reply
#4
Through-out the tutorial you speak as if you made it. Constantly 'I, I, I'.

If you don't know who made it, but you didn't, say so.
Reply
#5
ok? the only time i said I was in the begining and this part
Now, here is the weird part. For some reason while doing this the sprites when off the surface area. While on the max X they wouldnt blit. Sooo i could have; made the sprites into smaller surfaces such as nptopleft, npctopright etc or just increase the surface.
sooooo comment this out
Code:
' .lWidth = (MAX_MAPX + 1) * PIC_X
' .lHeight = (MAX_MAPY + 1) * PIC_Y

and put this in its spot
Code:
.lWidth = (MAX_MAPX + 1) * PIC_X + 32
.lHeight = (MAX_MAPY + 1) * PIC_Y + 32


and that part i made up on my own so i dont know what your so worked up about
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)