| Mirage Source http://www.miragesource.net/forums/ |
|
| 64x64 Npcs http://www.miragesource.net/forums/viewtopic.php?f=210&t=827 |
Page 1 of 1 |
| Author: | Forte [ Mon Dec 11, 2006 1:06 pm ] |
| Post subject: | 64x64 Npcs |
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 <= 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 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 <= 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 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 |
|
| Author: | Tony [ Mon Dec 11, 2006 2:26 pm ] |
| Post subject: | |
This isn't even your code 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 |
|
| Author: | Forte [ Mon Dec 11, 2006 10:18 pm ] |
| Post subject: | |
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 |
|
| Author: | Robin [ Mon Dec 11, 2006 10:21 pm ] |
| Post subject: | |
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. |
|
| Author: | Forte [ Mon Dec 11, 2006 11:26 pm ] |
| Post subject: | |
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 |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|