Guest User

Untitled

a guest
Oct 9th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Sub Render_Graphics()
  2. Dim x As Long
  3. Dim y As Long
  4. Dim i As Long
  5. Dim n As Long
  6.  
  7.     DX8.BeginScene
  8.    
  9.         For x = -1 To MAX_MAPX + 1
  10.             For y = -1 To MAX_MAPY + 1
  11.                 Call BltMapTile(x, y)
  12.             Next
  13.         Next
  14.        
  15.         For n = 1 To 9
  16.             If (tMap(n) <> 0) And (tMap(n) < MAX_MAPS + 1) Then
  17.                 For i = 1 To MAX_MAP_ITEMS
  18.                     If MapItem(i, tMap(n)).Num > 0 Then
  19.                         Call BltItem(i, tMap(n))
  20.                     End If
  21.                 Next
  22.             End If
  23.         Next
  24.        
  25.         For y = -1 To MAX_MAPY + 1
  26.             For i = 1 To High_Index
  27.                 If Player(i).y = y Then
  28.                     Call BltPlayer(i)
  29.                 End If
  30.             Next
  31.            
  32.             For n = 1 To 9
  33.                 If (tMap(n) <> 0) And (tMap(n) < MAX_MAPS + 1) Then
  34.                     For i = 1 To MAX_MAP_NPCS
  35.                         If MapNpc(i, tMap(n)).y = y Then
  36.                             Call BltNpc(i, tMap(n))
  37.                         End If
  38.                     Next
  39.                 End If
  40.             Next
  41.         Next
  42.        
  43.         For x = -1 To MAX_MAPX + 1
  44.             For y = -1 To MAX_MAPY + 1
  45.                 Call BltMapFringeTile(x, y)
  46.             Next
  47.         Next
  48.        
  49.         If BFPS Then
  50.             Call DX8.DrawText((MAX_MAPX + 1) * PIC_X - Len(Trim$("FPS: " & GameFPS)) * 10 - 3, 3, Trim$("FPS: " & GameFPS), DX8.ARGB(255, 255, 255, 255))
  51.         End If
  52.  
  53.        
  54.         For i = 1 To High_Index
  55.             Call DrawPlayerName(i)
  56.             Call DrawPlayerGuildName(i)
  57.         Next
  58.        
  59.         ' Draw map name
  60.        Call DX8.DrawText(DrawMapNameX, DrawMapNameY, map(5).Name, DX8.AcRGB(255, DrawMapNameColor))
  61.    
  62.         ' draw cursor and player location
  63.        If BLoc Then
  64.             Call DX8.DrawText(3, 3, Trim$("Cur X: " & CurX & " Y: " & CurY), DX8.ARGB(255, 255, 255, 255))
  65.             Call DX8.DrawText(3, 14, Trim$("Loc X: " & GetPlayerX(MyIndex) & " Y: " & GetPlayerY(MyIndex)), DX8.ARGB(255, 255, 255, 255))
  66.             Call DX8.DrawText(3, 25, Trim$("Map#:" & GetPlayerMap(MyIndex)), DX8.ARGB(255, 255, 255, 255))
  67.         End If
  68.                        
  69.         ' draw map attributes
  70.        If Editor = EDITOR_MAP Then
  71.             If frmMainGame.optAttribs.Value Then
  72.                 Call DrawMapAttributes
  73.             End If
  74.         End If
  75.  
  76.     Call DX8.EndScene
  77.  
  78. End Sub
  79.  
  80. '///// BltPLayer and BltNPC////////
  81. '///////////////////////////////////
  82. Sub BltPlayer(ByVal Index As Long)
  83. Dim Anim As Byte
  84. Dim x As Long, y As Long
  85. Dim x2 As Long, y2 As Long
  86. Dim i As Long
  87. Dim insight As Boolean
  88. Dim Sprite As Long, spriteleft As Long
  89. Dim spellnum As Long
  90.  
  91.  
  92.     Sprite = GetPlayerSprite(Index)
  93.     If Sprite = 0 Then Sprite = 1
  94.     DX8.SetTexture Tr_Sprites(Sprite)
  95.  
  96.             insight = False
  97.                 Select Case Player(Index).map
  98.                     Case map(5).Right
  99.                         insight = True
  100.                         x2 = MAX_MAPX + 1
  101.                         y2 = 0
  102.                     Case map(5).Left
  103.                         insight = True
  104.                         x2 = -1 * (MAX_MAPX + 1)
  105.                         y2 = 0
  106.                     Case map(5).Up
  107.                         insight = True
  108.                         x2 = 0
  109.                         y2 = -1 * (MAX_MAPY + 1)
  110.                     Case map(5).Down
  111.                         insight = True
  112.                         x2 = 0
  113.                         y2 = MAX_MAPY + 1
  114.                     Case map(4).Up 'north west
  115.                        insight = True
  116.                         x2 = -1 * (MAX_MAPX + 1)
  117.                         y2 = -1 * (MAX_MAPY + 1)
  118.                     Case map(4).Down 'south west
  119.                        insight = True
  120.                         x2 = -1 * (MAX_MAPX + 1)
  121.                         y2 = (MAX_MAPY + 1)
  122.                     Case map(6).Up 'north east
  123.                        insight = True
  124.                         x2 = (MAX_MAPX + 1)
  125.                         y2 = -1 * (MAX_MAPY + 1)
  126.                     Case map(4).Down ' south east
  127.                        insight = True
  128.                         x2 = (MAX_MAPX + 1)
  129.                         y2 = (MAX_MAPY + 1)
  130.                     Case Player(MyIndex).map
  131.                         insight = True
  132.                         x2 = 0
  133.                         y2 = 0
  134.                 End Select
  135.                
  136.             If insight = True Then
  137.                 Anim = 0
  138.                 If Player(Index).Attacking = 0 Then
  139.                     Select Case GetPlayerDir(Index)
  140.                         Case DIR_UP
  141.                             If Player(Index).YOffset < PIC_Y \ 2 Then Anim = 1
  142.                         Case DIR_DOWN
  143.                             If Player(Index).YOffset < PIC_Y \ -2 Then Anim = 1
  144.                         Case DIR_LEFT
  145.                             If Player(Index).XOffset < PIC_Y \ 2 Then Anim = 1
  146.                         Case DIR_RIGHT
  147.                             If Player(Index).XOffset < PIC_Y \ -2 Then Anim = 1
  148.                     End Select
  149.                 Else
  150.                     If Player(Index).AttackTimer + 500 > GetTickCount Then
  151.                         Anim = 2
  152.                     End If
  153.                 End If
  154.                
  155.                 If Player(Index).AttackTimer + 1000 < GetTickCount Then
  156.                     Player(Index).Attacking = 0
  157.                     Player(Index).AttackTimer = 0
  158.                 End If
  159.                
  160.     Select Case GetPlayerDir(Index)
  161.         Case DIR_UP
  162.             spriteleft = DIR_UP
  163.         Case DIR_RIGHT
  164.             spriteleft = DIR_RIGHT
  165.         Case DIR_DOWN
  166.             spriteleft = DIR_DOWN
  167.         Case DIR_LEFT
  168.             spriteleft = DIR_LEFT
  169.     End Select
  170.                
  171.     x = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
  172.     y = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset
  173.  
  174.     Call DX8.DrawTexture(x2 * PIC_X + x + StaticX, y2 * PIC_Y + y + StaticY, PIC_X, PIC_Y, (spriteleft * 3 + Anim) * (32), 0, PIC_X, PIC_Y, DX8.ARGB(255, 255, 255, 255), 512, 32)
  175.    
  176.         For i = 1 To MAX_SPELLANIM
  177.         spellnum = Player(Index).SpellAnimations(i).spellnum
  178.        
  179.         If spellnum > 0 Then
  180.             If Spell(spellnum).Pic > 0 Then
  181.        
  182.                 If Player(Index).SpellAnimations(i).Timer < GetTickCount Then
  183.                     Player(Index).SpellAnimations(i).FramePointer = Player(Index).SpellAnimations(i).FramePointer + 1
  184.                     Player(Index).SpellAnimations(i).Timer = GetTickCount + 120
  185.                                                                            
  186.                     If Player(Index).SpellAnimations(i).FramePointer >= 12 Then
  187.                         Player(Index).SpellAnimations(i).spellnum = 0
  188.                         Player(Index).SpellAnimations(i).Timer = 0
  189.                         Player(Index).SpellAnimations(i).FramePointer = 0
  190.                     End If
  191.                 End If
  192.            
  193.                 If Player(Index).SpellAnimations(i).spellnum > 0 Then
  194.            
  195.                     Call DX8.SetTexture(Tr_Spells(spellnum))
  196.                     Call DX8.DrawTexture(x, y, PIC_X, PIC_Y, Player(Index).SpellAnimations(i).FramePointer * SIZE_X, 0, PIC_X, PIC_Y, DX8.ARGB(255, 255, 255, 255), 512, 32)
  197.  
  198.                 End If
  199.                
  200.             End If
  201.         End If
  202.        
  203.     Next
  204.     End If
  205. End Sub
  206.  
  207. Public Sub BltNpc(ByVal MapNpcNum As Long, ByVal MapNum As Long)
  208. Dim Anim As Long
  209. Dim i As Long
  210. Dim spellnum As Long
  211. Dim x, x2 As Long
  212. Dim y, y2 As Long
  213. Dim Sprite As Long, spriteleft As Long
  214. Dim insight As Boolean
  215.  
  216.     ' Make sure that theres an npc there, and if not exit the sub
  217.    If MapNpc(MapNpcNum, MapNum).Num <= 0 Then
  218.         Exit Sub
  219.     End If
  220.  
  221.     Sprite = Npc(MapNpc(MapNpcNum, MapNum).Num).Sprite
  222.     DX8.SetTexture Tr_Sprites(Sprite)
  223.    
  224.             insight = False
  225.                 Select Case MapNum
  226.                     Case map(5).Right
  227.                         insight = True
  228.                         x2 = MAX_MAPX + 1
  229.                         y2 = 0
  230.                     Case map(5).Left
  231.                         insight = True
  232.                         x2 = -1 * (MAX_MAPX + 1)
  233.                         y2 = 0
  234.                     Case map(5).Up
  235.                         insight = True
  236.                         x2 = 0
  237.                         y2 = -1 * (MAX_MAPY + 1)
  238.                     Case map(5).Down
  239.                         insight = True
  240.                         x2 = 0
  241.                         y2 = MAX_MAPY + 1
  242.                     Case map(4).Up 'north west
  243.                        insight = True
  244.                         x2 = -1 * (MAX_MAPX + 1)
  245.                         y2 = -1 * (MAX_MAPY + 1)
  246.                     Case map(4).Down 'south west
  247.                        insight = True
  248.                         x2 = -1 * (MAX_MAPX + 1)
  249.                         y2 = (MAX_MAPY + 1)
  250.                     Case map(6).Up 'north east
  251.                        insight = True
  252.                         x2 = (MAX_MAPX + 1)
  253.                         y2 = -1 * (MAX_MAPY + 1)
  254.                     Case map(4).Down ' south east
  255.                        insight = True
  256.                         x2 = (MAX_MAPX + 1)
  257.                         y2 = (MAX_MAPY + 1)
  258.                     Case Player(MyIndex).map
  259.                         insight = True
  260.                         x2 = 0
  261.                         y2 = 0
  262.                 End Select
  263.                
  264. If insight Then
  265.     ' Check for animation
  266.    Anim = 0
  267.     If MapNpc(MapNpcNum, MapNum).Attacking = 0 Then
  268.         Select Case MapNpc(MapNpcNum, MapNum).Dir
  269.             Case DIR_UP
  270.                 If (MapNpc(MapNpcNum, MapNum).YOffset < SIZE_Y / 2) Then Anim = 1
  271.             Case DIR_DOWN
  272.                 If (MapNpc(MapNpcNum, MapNum).YOffset < SIZE_Y / 2 * -1) Then Anim = 1
  273.             Case DIR_LEFT
  274.                 If (MapNpc(MapNpcNum, MapNum).XOffset < SIZE_Y / 2) Then Anim = 1
  275.             Case DIR_RIGHT
  276.                 If (MapNpc(MapNpcNum, MapNum).XOffset < SIZE_Y / 2 * -1) Then Anim = 1
  277.         End Select
  278.     Else
  279.         If MapNpc(MapNpcNum, MapNum).AttackTimer + 500 > GetTickCount Then
  280.             Anim = 2
  281.         End If
  282.     End If
  283.    
  284.     ' Check to see if we want to stop making him attack
  285.    With MapNpc(MapNpcNum, MapNum)
  286.         If .AttackTimer + 1000 < GetTickCount Then
  287.             .Attacking = 0
  288.             .AttackTimer = 0
  289.         End If
  290.     End With
  291.    
  292.     Select Case MapNpc(MapNpcNum, MapNum).Dir
  293.         Case DIR_UP
  294.             spriteleft = DIR_UP
  295.         Case DIR_RIGHT
  296.             spriteleft = DIR_RIGHT
  297.         Case DIR_DOWN
  298.             spriteleft = DIR_DOWN
  299.         Case DIR_LEFT
  300.             spriteleft = DIR_LEFT
  301.     End Select
  302.    
  303.     'With rec
  304.    '    .Top = 0
  305.    '    .Bottom = DDS_Sprite(Sprite).SurfDescription.lHeight
  306.    '    .Left = (spriteleft * 3 + Anim) * (DDS_Sprite(Sprite).SurfDescription.lWidth / 12)
  307.    '    .Right = .Left + (DDS_Sprite(Sprite).SurfDescription.lWidth / 12)
  308.    'End With
  309.    
  310.     With MapNpc(MapNpcNum, MapNum)
  311.         x = .x * PIC_X + .XOffset
  312.         y = .y * PIC_Y + .YOffset
  313.     End With
  314.  
  315.     Call DX8.DrawTexture(x2 * PIC_X + x + StaticX, y2 * PIC_Y + y + StaticY, PIC_X, PIC_Y, (spriteleft * 3 + Anim) * (32), 0, PIC_X, PIC_Y, DX8.ARGB(255, 255, 255, 255), 512, 32)
  316.    
  317.    
  318.     ' ** Blit Spells Animations **
  319.    For i = 1 To MAX_SPELLANIM
  320.         spellnum = MapNpc(MapNpcNum, MapNum).SpellAnimations(i).spellnum
  321.        
  322.         If spellnum > 0 Then
  323.             If Spell(spellnum).Pic > 0 Then
  324.            
  325.                 If MapNpc(MapNpcNum, MapNum).SpellAnimations(i).Timer < GetTickCount Then
  326.                     MapNpc(MapNpcNum, MapNum).SpellAnimations(i).FramePointer = MapNpc(MapNpcNum, MapNum).SpellAnimations(i).FramePointer + 1
  327.                     MapNpc(MapNpcNum, MapNum).SpellAnimations(i).Timer = GetTickCount + 120
  328.                    
  329.                     If MapNpc(MapNpcNum, MapNum).SpellAnimations(i).FramePointer >= 12 Then
  330.                         MapNpc(MapNpcNum, MapNum).SpellAnimations(i).spellnum = 0
  331.                         MapNpc(MapNpcNum, MapNum).SpellAnimations(i).Timer = 0
  332.                         MapNpc(MapNpcNum, MapNum).SpellAnimations(i).FramePointer = 0
  333.                     End If
  334.                 End If
  335.            
  336.                 If MapNpc(MapNpcNum, MapNum).SpellAnimations(i).spellnum > 0 Then
  337.                     Call DX8.SetTexture(Tr_Spells(spellnum))
  338.                     Call DX8.DrawTexture(x + x2 * PIC_X, y + y2 * PIC_Y, PIC_X, PIC_Y, MapNpc(MapNpcNum, MapNum).SpellAnimations(i).FramePointer * SIZE_X, 0, PIC_X, PIC_Y, DX8.ARGB(255, 255, 255, 255), 512, 32)
  339.                 End If
  340.                
  341.             End If
  342.         End If
  343.        
  344.     Next
  345.     End If
  346. End Sub
Add Comment
Please, Sign In to add comment