Advertisement
Guest User

Untitled

a guest
Mar 13th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Sub DrawMapResource(ByVal Resource_num As Long, Optional ByVal screenShot As Boolean = False)
  2. Dim Resource_master As Long
  3. Dim Resource_state As Long
  4. Dim Resource_sprite As Long
  5. Dim rec As RECT
  6. Dim x As Long, y As Long
  7. Dim i As Long, Alpha As Long
  8.  
  9. ' If debug mode, handle error then exit out
  10. If Options.Debug = 1 Then On Error GoTo errorhandler
  11.  
  12. ' make sure it's not out of map
  13. If MapResource(Resource_num).x > Map.MaxX Then Exit Sub
  14. If MapResource(Resource_num).y > Map.MaxY Then Exit Sub
  15.  
  16. ' Get the Resource type
  17. Resource_master = Map.Tile(MapResource(Resource_num).x, MapResource(Resource_num).y).data1
  18.  
  19. If Resource_master = 0 Then Exit Sub
  20.  
  21. If Resource(Resource_master).ResourceImage = 0 Then Exit Sub
  22. ' Get the Resource state
  23. Resource_state = MapResource(Resource_num).ResourceState
  24.  
  25. If Resource_state = 0 Then ' normal
  26. Resource_sprite = Resource(Resource_master).ResourceImage
  27. ElseIf Resource_state = 1 Then ' used
  28. Resource_sprite = Resource(Resource_master).ExhaustedImage
  29. End If
  30.  
  31. ' cut down everything if we're editing
  32. If InMapEditor Then
  33. Resource_sprite = Resource(Resource_master).ExhaustedImage
  34. End If
  35.  
  36. ' src rect
  37. With rec
  38. .Top = 0
  39. .Bottom = Tex_Resource(Resource_sprite).Height
  40. .Left = 0
  41. .Right = Tex_Resource(Resource_sprite).Width
  42. End With
  43.  
  44. ' Set base x + y, then the offset due to size
  45. x = (MapResource(Resource_num).x * PIC_X) - (Tex_Resource(Resource_sprite).Width / 2) + 16
  46. y = (MapResource(Resource_num).y * PIC_Y) - Tex_Resource(Resource_sprite).Height + 32
  47.  
  48. If Options.STT = 1 Then
  49.  
  50. ' Semi Transparent Trees :D
  51. For i = 1 To Player_HighIndex
  52. If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
  53. If ConvertMapY(GetPlayerY(i)) < ConvertMapY(MapResource(Resource_num).y) And ConvertMapY(GetPlayerY(i)) > ConvertMapY(MapResource(Resource_num).y) - (Tex_Resource(Resource_sprite).Height) / 32 Then
  54. If ConvertMapX(GetPlayerX(i)) >= ConvertMapX(MapResource(Resource_num).x) - ((Tex_Resource(Resource_sprite).Width / 2) / 32) And ConvertMapX(GetPlayerX(i)) <= ConvertMapX(MapResource(Resource_num).x) + ((Tex_Resource(Resource_sprite).Width / 2) / 32) Then
  55. Alpha = 150
  56. Else
  57. Alpha = 255
  58. End If
  59. Else
  60. Alpha = 255
  61. End If
  62. End If
  63. Next
  64.  
  65. ' render it
  66. Call DrawResource(Resource_sprite, Alpha, x, y, rec)
  67.  
  68. Else
  69.  
  70. ' render it
  71. If Not screenShot Then
  72. Call DrawResource(Resource_sprite, x, y, rec)
  73. Else
  74. Call ScreenshotResource(Resource_sprite, x, y, rec)
  75. End If
  76.  
  77. End If
  78.  
  79. ' Error handler
  80. Exit Sub
  81. errorhandler:
  82. HandleError "DrawMapResource", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext
  83. Err.Clear
  84. Exit Sub
  85. End Sub
  86.  
  87. Private Sub DrawResource(ByVal Resource As Long, ByVal Alpha As Long, ByVal dX As Long, dY As Long, rec As RECT)
  88. Dim x As Long
  89. Dim y As Long
  90. Dim Width As Long
  91. Dim Height As Long
  92. Dim destRect As RECT
  93.  
  94. ' If debug mode, handle error then exit out
  95. If Options.Debug = 1 Then On Error GoTo errorhandler
  96.  
  97. If Resource < 1 Or Resource > NumResources Then Exit Sub
  98.  
  99. x = ConvertMapX(dX)
  100. y = ConvertMapY(dY)
  101.  
  102. Width = (rec.Right - rec.Left)
  103. Height = (rec.Bottom - rec.Top)
  104.  
  105. If Options.STT = 1 Then
  106. RenderTexture Tex_Resource(Resource), x, y, rec.Left, rec.Top, rec.Right - rec.Left, rec.Bottom - rec.Top, rec.Right - rec.Left, rec.Bottom - rec.Top, D3DColorRGBA(255, 255, 255, Alpha)
  107.  
  108.  
  109. Else
  110.  
  111. RenderTexture Tex_Resource(Resource), x, y, rec.Left, rec.Top, rec.Right - rec.Left, rec.Bottom - rec.Top, rec.Right - rec.Left, rec.Bottom - rec.Top, D3DColorRGBA(255, 255, 255, 255)
  112.  
  113. End If
  114.  
  115. ' Error handler
  116. Exit Sub
  117. errorhandler:
  118. HandleError "DrawResource", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext
  119. Err.Clear
  120. Exit Sub
  121. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement