Akianzax

AR3 ~ Advanced Hud

Jul 10th, 2014
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 31.30 KB | None | 0 0
  1. #                            ~ Akian~RGSS3 ~
  2.  
  3. # =============================== Español ======================================
  4.  
  5. # Nombre del script: AR3 ~ Advanced Hud
  6. # Scripter: Akian~RGSS3
  7. # Requiere?: Imagenes del demo
  8. # Versión: 1.0
  9.  
  10. # Historial:
  11. # 1.0 Comienzo y Finalización del script
  12.  
  13. # Este script te permite un hud altamente modificable a base de sprites.
  14. # Contiene técnicas de scripteo avanzado (si eres scripter puedes revisarlas
  15. # para enterarte de cómo se logra algo así).
  16. # Puedes cambiar las imágenes (deben mantener el mismo nombre) a tu gusto
  17. # así podrás armar el hud como tu quieras, o simplemente modifica la posición
  18. # de las imágenes por default en la region editable.
  19.  
  20. # ~ Script call ~
  21. # hud_visible(true)     para activar el hud
  22. # hud_visible(false)    para desactivarlo
  23.  
  24. #===============================================================================
  25. # Condiciones de uso:
  26. # Puedes usar libremente este script en proyectos comerciales y no comerciales
  27. # Los créditos son requeridos, por el trabajo, el esfuerzo, el sudor, bueno no
  28. # tanto por el sudor.
  29. # Si posteas este script en algún foro debes señalar la página oficial
  30. # http://akianrgss3.wordpress.com/
  31. # También nombrar la página en los créditos si lo usas para un proyecto.
  32. # NO puedes usar las imágenes del demo en un proyecto comercial.
  33. #===============================================================================
  34.  
  35. # =============================== English ======================================
  36.  
  37. # Name of the script: AR3 ~ Advanced Hud
  38. # Scripter: Akian~RGSS3
  39. # Need?: Images from the demo
  40. # Versión: 1.0
  41.  
  42. # Historial:
  43. # 1.0 Start and finish the script
  44.  
  45. # This script allows a hud on the map with advanced techniques on sprites.
  46. # You can change the images on Graphics/Advanced_Hud folder and the position
  47. # in the editable region below to make your own hud.
  48.  
  49. # ~ Script call ~
  50. # hud_visible(true)     to enable the hud
  51. # hud_visible(false)    to disable the hud
  52.  
  53. #===============================================================================
  54. # Terms of use:
  55. # Free to use in comercial and non comercial projects
  56. # Credits are required and the mention of my web
  57. # http://akianrgss3.wordpress.com/
  58. # also you has to mention my page if you post this script in other web/blog
  59. # Sry for this, but you are NOT allowed to use the images from the demo
  60. # in a comercial project.
  61. #===============================================================================
  62.  
  63.  
  64. $imported = {} if $imported.nil?
  65. $imported["AR3_Advanced_Hud"] = true
  66.  
  67. module AR3_ADVANCED_HUD
  68.  
  69. #===============================================================================
  70. #
  71. #                         REGION EDITABLE
  72. #
  73. #===============================================================================
  74.  
  75. #~~~~~~~~~~~~~~~~~~
  76. # Hud
  77. #~~~~~~~~~~~~~~~~~~
  78. # Posición x del hud  | x position
  79.   HUD_POSITION_X    = -5
  80.  
  81. # Posición y del hud  | y position
  82.   HUD_POSITION_Y    = -5
  83.    
  84. # Visible desde el inicio? | initial visible?
  85. # true   = yes
  86. # false  = no
  87.   INITIAL_VISIBLE   = true
  88.  
  89. # Posición z del hud
  90.   HUD_Z             = 70
  91. #~~~~~~~~~~~~~~~~~~
  92. # Face
  93. #~~~~~~~~~~~~~~~~~~
  94.  
  95. # Mostrar la cara del personaje? true / false
  96. # Para esto se necesitara una imagen en la carpeta Graphics/Advanced_Hud
  97. # con la cara del actor y debe obligadamente tener el siguiente nombre
  98. # ACTOR_ID + _Face
  99. # Ex: Actor1_Face   Actor2_Face  etc
  100.  
  101. # Show face graphic? true / false
  102. # You will need the face image of the actor and name it ACTOR_ID + _Face
  103. # Ex: Actor1_Face    Actor2_Face  etc
  104.   DRAW_FACE         = true
  105.  
  106. # Posición x de la cara  | x position
  107.   FACE_POSITION_X   = 3
  108.  
  109. # Posición y de la cara  | y position
  110.   FACE_POSITION_Y   = 12
  111.  
  112. #~~~~~~~~~~~~~~~~~~
  113. #  Hp
  114. #~~~~~~~~~~~~~~~~~~
  115.  
  116. # Mostrar barra de vida? true / false
  117. # Show hp bar? true / false
  118.   DRAW_HP           = true
  119.  
  120. # Posición x de la barra de vida | x position
  121.   HP_POSITION_X     = 95
  122.  
  123. # Posición y de la barra de vida | y position
  124.   HP_POSITION_Y     = 57
  125.  
  126. #~~~~~~~~~~~~~~~~~~
  127. # Mp
  128. #~~~~~~~~~~~~~~~~~~
  129.  
  130. # Mostrar barra de mp? true / false
  131. # Show mp bar? true / false
  132.   DRAW_MP           = true
  133.  
  134. # Posición x de la barra de mp | x position
  135.   MP_POSITION_X     = 83
  136.  
  137. # Posición y de la barra de mp | y position
  138.   MP_POSITION_Y     = 78
  139.  
  140. #~~~~~~~~~~~~~~~~~~
  141. # Level
  142. #~~~~~~~~~~~~~~~~~~
  143.  
  144. # Mostrar Nivel? true / false
  145. # Show level?  true / false
  146.   LV_SPRITE            = true
  147.  
  148. # Posición x de la capa (layer) | level layer position x
  149.   LV_POSITION_X        = 60
  150.  
  151. # Posición y de la capa (layer) | level layer position y
  152.   LV_POSITION_Y        = 87
  153.  
  154. # Posición x del número para el nivel | level number position x
  155.   LEVEL_NUMBER_POSITION_X   = 95
  156.  
  157. # Posición y del número para el nivel  | level number position y
  158.   LEVEL_NUMBER_POSITION_Y   = 108
  159.  
  160. #~~~~~~~~~~~~~~~~~~
  161. # Hp Mp
  162. #~~~~~~~~~~~~~~~~~~
  163.  
  164. # Mostrar gráfico Hp_Mp? true / false
  165. # Show words of Hp_Mp? true / false
  166.   DRAW_WORD              = true
  167.  
  168. # Posición x del Hp_Mp | x position
  169.   WORD_POSITION_X        = 88
  170.  
  171. # Posición x del Hp_Mp | y position                                  
  172.   WORD_POSITION_Y        = 50
  173.  
  174. #~~~~~~~~~~~~~~~~~~
  175. # Nombre
  176. #~~~~~~~~~~~~~~~~~~
  177.  
  178. # Mostrar nombre del personaje? true / false
  179. # Show name? true / false
  180.   DRAW_NAME              = true
  181.  
  182. # Posición x del nombre  | x position
  183.   NAME_POSITION_X        = 110
  184.  
  185. # Posición y del nombre  | y position
  186.   NAME_POSITION_Y        = 10
  187.  
  188. # Fuente del nombre  | name font
  189.   NAME_FONT              = "Georgia"
  190.  
  191. # Tamaño de fuente  | font size
  192.   NAME_FONT_SIZE         = 18
  193.  
  194. # Italic a la fuente?   | font italic?
  195.   NAME_FONT_ITALIC       = true
  196.  
  197. # Bold a la fuente?  | font bold?
  198.   NAME_FONT_BOLD         = true
  199.  
  200. # Color de la fuente                rojo  verde  azul  gris  
  201. # Font color
  202.   NAME_FONT_COLOR        = Color.new(255,  255,  255,  255)
  203.  
  204. # Sombra del nombre?
  205. # Name shadow?
  206.   NAME_SHADOW            = true
  207.  
  208. # Color de la sombra?               rojo verde azul gris
  209. # Shadow color
  210.   NAME_SHADOW_FONT_COLOR = Color.new(100,    100,   100,   255)
  211.  
  212. #~~~~~~~~~~~~~~~~~~
  213. # Número Hp
  214. #~~~~~~~~~~~~~~~~~~
  215.  
  216. # Mostrar número de hp? true / false
  217. # Show hp number? true / false
  218.   DRAW_HP_NUMBER         = true
  219.  
  220. #~~~~~~~~~~~~~~~~~~
  221. # Número Mp
  222. #~~~~~~~~~~~~~~~~~~
  223.  
  224. # Mostrar número de mp? true / false
  225. # Show mp number? true / false
  226.   DRAW_MP_NUMBER        = true
  227.  
  228. #~~~~~~~~~~~~~~~~~~
  229. # Oro
  230. #~~~~~~~~~~~~~~~~~~  
  231.  
  232. # Mostrar oro? true / false
  233. # Show gold? true / false
  234.   DRAW_GOLD             = true
  235.  
  236. # Posición x del oro  | x position
  237.   GOLD_POSITION_X       = 372
  238.  
  239. # Posición y del oro  | y position
  240.   GOLD_POSITION_Y       = 350
  241.  
  242. # Posición x del número del oro  | x position of the number
  243.   GOLD_NUMBER_X         = 542
  244.  
  245. # Posición y del número del oro  | y position of the number
  246.   GOLD_NUMBER_Y         = 395
  247.  
  248. #===============================================================================
  249. #
  250. #                      FIN DE LA REGION EDITABLE
  251. #
  252. #===============================================================================
  253. end
  254.  
  255. if true  # Set this to true to enable the script
  256.          # Deja en true para activar el script
  257. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  258. # Modulo Cache
  259. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  260. module Cache
  261.   #--------------------------------------------------------------------------
  262.   # ▼ Cache Advanced_Hud
  263.   #--------------------------------------------------------------------------
  264.   def self.advanced_hud(filename)
  265.     load_bitmap("Graphics/Advanced_Hud/", filename)
  266.   end
  267. end
  268.  
  269. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  270. # Seteando acceso a la visibilidad del hud
  271. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  272. class Game_System
  273.   alias akian_advanced_hud_visible_zack        initialize
  274.  
  275.   attr_accessor :hud_visible
  276.  
  277.   def initialize
  278.     akian_advanced_hud_visible_zack
  279.     @hud_visible = AR3_ADVANCED_HUD::INITIAL_VISIBLE
  280.   end
  281. end
  282.  
  283. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  284. # Clase para los scripts calls
  285. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  286. class Game_Interpreter
  287.   def hud_visible(valor)
  288.     $game_system.hud_visible = valor
  289.   end
  290. end
  291.  
  292. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  293. # Clase Scene_Map donde se ejecuta todo lo relacionado a la escena
  294. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  295. class Spriteset_Map
  296.   alias akian_avanced_hud_start_zack       initialize
  297.   alias akian_advanced_hud_update_zack     update
  298.   alias akian_advanced_hud_dispose_zack    dispose
  299.  
  300.   #--------------------------------------------------------------------------
  301.   # ▼ Creando el hud en el mapa
  302.   #--------------------------------------------------------------------------  
  303.   def initialize
  304.     create_advanced_hud
  305.     akian_avanced_hud_start_zack
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # ▼ Dispose
  309.   #--------------------------------------------------------------------------  
  310.   def dispose
  311.     execute_hud_dispose
  312.     akian_advanced_hud_dispose_zack
  313.   end
  314.   #--------------------------------------------------------------------------
  315.   # ▼ Actualización
  316.   #--------------------------------------------------------------------------  
  317.   def update
  318.     advanced_hud_update
  319.     akian_advanced_hud_update_zack
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # ▼ Creando hud
  323.   #--------------------------------------------------------------------------  
  324.   def create_advanced_hud
  325.     @advanced_hud   = Advanced_Hud.new
  326.   end
  327.   #--------------------------------------------------------------------------
  328.   # ▼ Actualización del hud
  329.   #--------------------------------------------------------------------------  
  330.   def advanced_hud_update
  331.      return if @advanced_hud == nil
  332.     @advanced_hud.update
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # ▼ Ejecutando el dispose
  336.   #--------------------------------------------------------------------------  
  337.   def execute_hud_dispose
  338.     return if @advanced_hud == nil
  339.     @advanced_hud.dispose
  340.     @advanced_hud = nil
  341.   end
  342. end
  343.  
  344. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  345. # Advanced_Hud creación de sprites
  346. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  347. class Advanced_Hud
  348.   include AR3_ADVANCED_HUD
  349.   #--------------------------------------------------------------------------
  350.   # ▼ Inicializando - seteando el hud
  351.   #--------------------------------------------------------------------------  
  352.   def initialize
  353.     setup_start
  354.     create_hud
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # ▼ Seteando el comienzo
  358.   #--------------------------------------------------------------------------
  359.   def setup_start
  360.     @actor                    = $game_party.members[0]
  361.     @hp_meter_image           = Cache.advanced_hud("Hp_Meter")
  362.     @hp_meter_cw              = @hp_meter_image.width
  363.     @hp_meter_ch              = @hp_meter_image.height
  364.     @mp_meter_image           = Cache.advanced_hud("Mp_Meter")
  365.     @mp_meter_cw              = @mp_meter_image.width
  366.     @mp_meter_ch              = @mp_meter_image.height
  367.     @lv_number_image          = Cache.advanced_hud("Number2")
  368.     @lv_number_cw             = @lv_number_image.width / 10
  369.     @lv_number_ch             = @lv_number_image.height
  370.     @hp_number_image          = Cache.advanced_hud("Number")
  371.     @hp_number_cw             = @hp_number_image.width / 10
  372.     @hp_number_ch             = @hp_number_image.height
  373.     @mp_number_image          = Cache.advanced_hud("Number")
  374.     @mp_number_cw             = @mp_number_image.width / 10
  375.     @mp_number_ch             = @mp_number_image.height    
  376.     @gold_number_image        = Cache.advanced_hud("Gold_Number")
  377.     @gold_number_cw           = @gold_number_image.width / 10
  378.     @gold_number_ch           = @gold_number_image.height
  379.   end
  380.  
  381.   #--------------------------------------------------------------------------
  382.   # ▼ Creando sprites
  383.   #--------------------------------------------------------------------------  
  384.   def create_hud  
  385.     create_hud_initial
  386.     hp_meter
  387.     mp_meter
  388.     create_level_number
  389.     create_face
  390.     create_lv_sprite
  391.     create_word
  392.     create_name
  393.     create_hp_number
  394.     create_mp_number
  395.     create_gold_number
  396.     create_gold
  397.     end
  398.   #--------------------------------------------------------------------------
  399.   # ▼ Visibilidad
  400.   #--------------------------------------------------------------------------  
  401.     def visible?
  402.     return false if $game_system.hud_visible
  403.     return true
  404.   end
  405. end
  406. #===============================================================================
  407. # Creando hud inicial
  408. #===============================================================================
  409. class Advanced_Hud
  410.  
  411.   def create_hud_initial
  412.     @hud_initial         = Sprite.new
  413.     @hud_initial.bitmap  = Cache.advanced_hud("Hud")
  414.     @hud_initial.x       = HUD_POSITION_X
  415.     @hud_initial.y       = HUD_POSITION_Y
  416.     @hud_initial.z       = HUD_Z - 3
  417.     @hud_initial.opacity = 0 if visible?
  418.   end
  419.  
  420.   def refresh_hud_initial
  421.     @hud_initial.opacity -= 5 if visible?
  422.     @hud_initial.opacity += 5 if !visible?
  423.   end
  424. end
  425.  
  426.  
  427. #===============================================================================
  428. # Creando Barra de Vida
  429. #===============================================================================
  430. class Advanced_Hud
  431.  
  432.   def hp_meter
  433.     return if !DRAW_HP
  434.       @hp_meter = Sprite.new
  435.       @hp_meter.bitmap = Bitmap.new(@hp_meter_cw,@hp_meter_ch)
  436.       @hp_meter.z = HUD_Z + 4
  437.       @hp_meter.x = HUD_POSITION_X + HP_POSITION_X
  438.       @hp_meter.y = HUD_POSITION_Y + HP_POSITION_Y
  439.       @hp_meter.opacity = 0 if visible?
  440.   end
  441.   #--------------------------------------------------------------------------
  442.   # ▼ Actualizando barra de vida
  443.   #--------------------------------------------------------------------------
  444.   def refresh_hp
  445.     return if !DRAW_HP
  446.       @hp_meter.bitmap.clear
  447.       meter_width = @hp_meter_cw * @actor.hp / @actor.mhp rescue nil
  448.       meter_width = 0 if meter_width == nil
  449.       meter_src_rect = Rect.new(0, 0 , meter_width, @hp_meter_ch)
  450.       @hp_meter.bitmap.blt(0, 0, @hp_meter_image, meter_src_rect)
  451.       @hp_meter.opacity -= 5 if visible?
  452.       @hp_meter.opacity += 5 if !visible?
  453.     end
  454.   end
  455.  
  456. #===============================================================================
  457. # Creando Número Hp
  458. #===============================================================================
  459. class Advanced_Hud
  460.  
  461.   def create_hp_number
  462.     return if !DRAW_HP_NUMBER
  463.     @hp_number            = Sprite.new
  464.     @hp_number.bitmap     = Bitmap.new(@hp_number_cw * 4, @hp_number_ch)
  465.     @hp_number.x          = HUD_POSITION_X + HP_POSITION_X + 103
  466.     @hp_number.y          = HUD_POSITION_Y + HP_POSITION_Y + 5
  467.     @hp_number.z          = HUD_Z + 6
  468.     @hp_number.zoom_y     = 0.7
  469.     @hp_number.opacity    = 0 if visible?
  470.   end
  471.   #--------------------------------------------------------------------------
  472.   # ▼ Actualizando número hp
  473.   #--------------------------------------------------------------------------  
  474.   def refresh_hp_number
  475.     return if !DRAW_HP_NUMBER
  476.     @hp_number.bitmap.clear
  477.     @old_number           = @actor.hp
  478.     number_value          = @actor.hp.to_s.split(//)
  479.     for r in 0..number_value.size - 1
  480.       number_value_abs = number_value[r].to_i
  481.       nsrc_rect        = Rect.new(@hp_number_cw * number_value_abs, 0 , @hp_number_cw, @hp_number_ch)
  482.       @hp_number.bitmap.blt(@hp_number_cw * r, 0, @hp_number_image, nsrc_rect)
  483.     end
  484.     @hp_number.opacity  -= 5 if visible?
  485.     @hp_number.opacity += 5 if !visible?
  486.     @hp_number.x = HUD_POSITION_X + HP_POSITION_X + 103 - (@hp_number_cw * number_value.size)
  487.   end
  488. end
  489.  
  490. #===============================================================================
  491. # Creando Barra de MP
  492. #===============================================================================  
  493. class Advanced_Hud
  494.    
  495.     def mp_meter
  496.       return if !DRAW_MP
  497.       @mp_meter             = Sprite.new
  498.       @mp_meter.bitmap      = Bitmap.new(@mp_meter_cw, @mp_meter_ch)
  499.       @mp_meter.z           = HUD_Z + 4
  500.       @mp_meter.x           = HUD_POSITION_X + MP_POSITION_X
  501.       @mp_meter.y           = HUD_POSITION_Y + MP_POSITION_Y
  502.       @mp_meter.opacity     = 0 if visible?
  503.     end
  504.   #--------------------------------------------------------------------------
  505.   # ▼ Actualizando barra mp
  506.   #--------------------------------------------------------------------------    
  507.      def refresh_mp
  508.        return if !DRAW_MP
  509.        @mp_meter.bitmap.clear
  510.        meter_width = @mp_meter_cw * @actor.mp / @actor.mmp rescue nil
  511.        meter_width = 0 if meter_width == nil
  512.        meter_src_rect   = Rect.new(0, 0, meter_width, @mp_meter_ch)
  513.        @mp_meter.bitmap.blt(0, 0, @mp_meter_image, meter_src_rect)
  514.        @mp_meter.opacity -= 5 if visible?
  515.        @mp_meter.opacity += 5 if !visible?
  516.      end  
  517.    end
  518. #===============================================================================
  519. # Creando Número Mp
  520. #===============================================================================
  521. class Advanced_Hud
  522.  
  523.   def create_mp_number
  524.     return if !DRAW_MP_NUMBER
  525.     @mp_number            = Sprite.new
  526.     @mp_number.bitmap     = Bitmap.new(@mp_number_cw * 4, @mp_number_ch)
  527.     @mp_number.x          = HUD_POSITION_X + MP_POSITION_X + 113
  528.     @mp_number.y          = HUD_POSITION_Y + MP_POSITION_Y + 5
  529.     @mp_number.z          = HUD_Z + 6
  530.     @mp_number.zoom_y     = 0.7
  531.     @mp_number.opacity    = 0 if visible?
  532.   end
  533.   #--------------------------------------------------------------------------
  534.   # ▼ Actualizando número mp
  535.   #--------------------------------------------------------------------------  
  536.   def refresh_mp_number
  537.     return if !DRAW_MP_NUMBER
  538.     @mp_number.bitmap.clear
  539.     @old_number           = @actor.mp
  540.     number_value          = @actor.mp.to_s.split(//)
  541.     for r in 0..number_value.size - 1
  542.       number_value_abs = number_value[r].to_i
  543.       nsrc_rect        = Rect.new(@mp_number_cw * number_value_abs, 0 , @mp_number_cw, @mp_number_ch)
  544.       @mp_number.bitmap.blt(@mp_number_cw * r, 0, @mp_number_image, nsrc_rect)
  545.     end
  546.       @mp_number.opacity -= 5 if visible?
  547.       @mp_number.opacity += 5 if !visible?
  548.       @mp_number.x   = HUD_POSITION_X + MP_POSITION_X + 113 - (@mp_number_cw * number_value.size)
  549.   end
  550. end
  551.  
  552. #===============================================================================
  553. # Creando cara del personaje
  554. #===============================================================================
  555. class Advanced_Hud
  556.  
  557.     def create_face
  558.       return if !DRAW_FACE
  559.         @face                = Sprite.new
  560.         @face.bitmap         = Cache.advanced_hud("Actor" + @actor.id.to_s + "_Face")
  561.         @face.z              = HUD_Z + 5
  562.         @face.x              = HUD_POSITION_X + FACE_POSITION_X
  563.         @face.y              = HUD_POSITION_Y + FACE_POSITION_Y
  564.         @face.opacity        = 0 if visible?
  565.     end
  566.   #--------------------------------------------------------------------------
  567.   # ▼ Actualizando cara
  568.   #--------------------------------------------------------------------------    
  569.     def refresh_face
  570.       return if !DRAW_FACE
  571.       @face.bitmap        = Cache.advanced_hud("Actor" + @actor.id.to_s + "_Face")
  572.       @face.opacity -= 5 if visible?
  573.       @face.opacity += 5 if !visible?
  574.     end
  575.   end
  576.  
  577. #===============================================================================
  578. # Creando Layer de Level
  579. #===============================================================================  
  580. class Advanced_Hud
  581.  
  582.     def create_lv_sprite
  583.       return if !LV_SPRITE
  584.       @lv_sprite           = Sprite.new
  585.       @lv_sprite.bitmap    = Cache.advanced_hud("Level")
  586.       @lv_sprite.z         = HUD_Z + 3
  587.       @lv_sprite.x         = HUD_POSITION_X + LV_POSITION_X
  588.       @lv_sprite.y         = HUD_POSITION_Y + LV_POSITION_Y
  589.       @lv_sprite.opacity   = 0 if visible?
  590.     end
  591.   #--------------------------------------------------------------------------
  592.   # ▼ Actualizando level
  593.   #--------------------------------------------------------------------------    
  594.     def refresh_lv_sprite
  595.       return if !LV_SPRITE
  596.       @lv_sprite.opacity -= 5 if visible?
  597.       @lv_sprite.opacity += 5 if !visible?
  598.     end
  599.   end
  600.  
  601. #===============================================================================
  602. # Creando sprite Hp y MP
  603. #===============================================================================    
  604. class Advanced_Hud
  605.  
  606.     def create_word
  607.       return if !DRAW_WORD
  608.         @word                = Sprite.new
  609.         @word.bitmap         = Cache.advanced_hud("Hp_Mp")
  610.         @word.z              = HUD_Z + 6
  611.         @word.x              = HUD_POSITION_X + WORD_POSITION_X
  612.         @word.y              = HUD_POSITION_Y + WORD_POSITION_Y
  613.         @word.opacity        = 0 if visible?
  614.     end
  615.   #--------------------------------------------------------------------------
  616.   # ▼ Actualizando sprite Hp y Mp
  617.   #--------------------------------------------------------------------------    
  618.     def refresh_word
  619.       return if !DRAW_WORD
  620.         @word.opacity -= 5 if visible?
  621.         @word.opacity += 5 if !visible?
  622.     end  
  623.   end
  624.  
  625. #===============================================================================
  626. # Creando número de nivel
  627. #===============================================================================
  628. class Advanced_Hud
  629.  
  630.   def create_level_number
  631.       return if !LV_SPRITE
  632.       @lv_number = Sprite.new
  633.       @lv_number.bitmap = Bitmap.new(@lv_number_cw * 2, @lv_number_ch)
  634.       @lv_number.z = HUD_Z + 4
  635.       @lv_number.x = HUD_POSITION_X + LEVEL_NUMBER_POSITION_X
  636.       @lv_number.y = HUD_POSITION_Y + LEVEL_NUMBER_POSITION_Y
  637.       @lv_number.opacity  = 0 if visible?
  638.       @lv_number.zoom_x   = 0.8
  639.       @lv_number.zoom_y   = 0.8
  640.     end
  641.   #--------------------------------------------------------------------------
  642.   # ▼ Actualizando número de level
  643.   #--------------------------------------------------------------------------    
  644.   def refresh_level_number
  645.     return if !LV_SPRITE
  646.       @lv_number.bitmap.clear    
  647.       number_value = @actor.level.abs.to_s.split(//)
  648.       for r in 0..number_value.size - 1        
  649.          number_value_abs = number_value[r].to_i
  650.          nsrc_rect = Rect.new(@lv_number_cw * number_value_abs, 0, @lv_number_cw, @lv_number_ch)
  651.          @lv_number.bitmap.blt(@lv_number_cw *  r, 0, @lv_number_image, nsrc_rect)
  652.        end      
  653.        @lv_number.opacity -= 5 if visible?
  654.        @lv_number.opacity += 5 if !visible?
  655.        @lv_number.x  = HUD_POSITION_X + LEVEL_NUMBER_POSITION_X - (number_value.size * 5)
  656.      end      
  657.    end
  658. #===============================================================================
  659. # Creando nombre del personaje
  660. #===============================================================================
  661. class Advanced_Hud
  662.  
  663.   def create_name
  664.     return if !DRAW_NAME
  665.       @name                    = Sprite.new
  666.       @name.bitmap             = Bitmap.new(160, 32)
  667.       @name.bitmap.font.name   = NAME_FONT
  668.       @name.bitmap.font.size   = NAME_FONT_SIZE
  669.       @name.bitmap.font.bold   = NAME_FONT_BOLD
  670.       @name.bitmap.font.italic = NAME_FONT_ITALIC
  671.       @name.bitmap.font.color  = NAME_FONT_COLOR
  672.       @name.x                  = HUD_POSITION_X + NAME_POSITION_X
  673.       @name.y                  = HUD_POSITION_Y + NAME_POSITION_Y
  674.       @name.z                  = HUD_Z + 6
  675.     if NAME_SHADOW
  676.       @name.bitmap.font.color = NAME_SHADOW_FONT_COLOR
  677.       @name.bitmap.draw_text(3, 3, 160, 32, @actor.name, 0)
  678.       @name.bitmap.font.color  = NAME_FONT_COLOR
  679.   end
  680.       @name.bitmap.draw_text(0, 0, 160, 32, @actor.name, 0)
  681.       @name.opacity            = 0 if visible?
  682.       refresh_name
  683.   end
  684.   #--------------------------------------------------------------------------
  685.   # ▼ Actualizando nombre
  686.   #--------------------------------------------------------------------------  
  687.   def refresh_name
  688.     return if !DRAW_NAME
  689.     @name.bitmap.clear
  690.     if NAME_SHADOW
  691.       @name.bitmap.font.color = NAME_SHADOW_FONT_COLOR
  692.       @name.bitmap.draw_text(3, 3, 160, 32, @actor.name, 0)
  693.       @name.bitmap.font.color  = NAME_FONT_COLOR
  694.   end
  695.       @name.bitmap.draw_text(0, 0, 160, 32, @actor.name, 0)
  696.       @name.opacity -= 5 if visible?
  697.       @name.opacity += 5 if !visible?
  698.   end
  699. end
  700.  
  701. #===============================================================================
  702. # Creando oro
  703. #===============================================================================
  704. class Advanced_Hud
  705.  
  706.   def create_gold
  707.     return if !DRAW_GOLD
  708.       @gold_layout           = Sprite.new
  709.       @gold_layout.bitmap    = Cache.advanced_hud("Gold_Layout")
  710.       @gold_layout.x         = GOLD_POSITION_X
  711.       @gold_layout.y         = GOLD_POSITION_Y
  712.       @gold_layout.z         = HUD_Z + 2
  713.       @gold_layout.opacity   = 0 if visible?
  714.   end
  715.  
  716.   def refresh_gold
  717.       return if !DRAW_GOLD
  718.       @gold_layout.opacity  -= 5 if visible?
  719.       @gold_layout.opacity  += 5 if !visible?
  720.   end
  721.  
  722.  
  723.   def create_gold_number
  724.     return if !DRAW_GOLD
  725.       @gold_number           = Sprite.new
  726.       @gold_number.bitmap    = Bitmap.new(@gold_number_cw * 8 , @gold_number_ch)
  727.       @gold_number.x         = GOLD_NUMBER_X
  728.       @gold_number.y         = GOLD_NUMBER_Y
  729.       @gold_number.z         = HUD_Z + 4
  730.       @gold_number.opacity    = 0 if visible?
  731.   end
  732.  
  733.   def refresh_gold_number
  734.     return if !DRAW_GOLD
  735.         @gold_number.bitmap.clear
  736.         number_value = $game_party.gold.abs.to_s.split(//)
  737.     for r in 0..number_value.size - 1
  738.         number_value_abs   = number_value[r].to_i
  739.         nsrc_rect   = Rect.new(@gold_number_cw * number_value_abs, 0, @gold_number_cw, @gold_number_ch)
  740.         @gold_number.bitmap.blt(@gold_number_cw * r, 0, @gold_number_image, nsrc_rect)
  741.     end
  742.         @gold_number.opacity    -= 5 if visible?
  743.         @gold_number.opacity    += 5 if !visible?
  744.         @gold_number.x   =  GOLD_NUMBER_X - (@gold_number_cw * number_value.size)
  745.   end
  746. end
  747.  
  748. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  749. # Advanced_Hud update
  750. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  751. class Advanced_Hud  
  752.  
  753.   def update_hud
  754.       refresh_hud_initial
  755.       refresh_hp
  756.       refresh_mp
  757.       refresh_level_number
  758.       refresh_face
  759.       refresh_lv_sprite
  760.       refresh_word
  761.       refresh_name
  762.       refresh_hp_number
  763.       refresh_mp_number
  764.       refresh_gold_number
  765.       refresh_gold
  766.     end    
  767.   #--------------------------------------------------------------------------
  768.   # Actualización de todos los sprites
  769.   #--------------------------------------------------------------------------  
  770.   def update
  771.     update_hud
  772.   end
  773. end
  774.  
  775. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  776. # Advanced_Hud Dispose
  777. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  778. class Advanced_Hud
  779.  
  780.     def dispose
  781.       dispose_hp_meter
  782.       dispose_mp_meter
  783.       dispose_face
  784.       dispose_lv_sprite
  785.       dispose_word
  786.       dispose_level_number
  787.       dispose_name
  788.       dispose_hp_number
  789.       dispose_mp_number
  790.       dispose_gold_layout
  791.       dispose_gold_number
  792.   end
  793.   #--------------------------------------------------------------------------
  794.   # ▼ Dispose barra de vida
  795.   #--------------------------------------------------------------------------  
  796.   def dispose_hp_meter
  797.     return if @hp_meter == nil
  798.     @hp_meter.bitmap.dispose
  799.     @hp_meter.dispose
  800.   end
  801.   #--------------------------------------------------------------------------
  802.   # ▼ Dispose barra de mp
  803.   #--------------------------------------------------------------------------    
  804.   def dispose_mp_meter
  805.     return if @mp_meter == nil
  806.     @mp_meter.bitmap.dispose
  807.     @mp_meter.dispose
  808.   end
  809.   #--------------------------------------------------------------------------
  810.   # ▼ Dispose cara
  811.   #--------------------------------------------------------------------------    
  812.   def dispose_face
  813.     return if @face == nil
  814.     @face.bitmap.dispose
  815.     @face.dispose
  816.   end
  817.   #--------------------------------------------------------------------------
  818.   # ▼ Dispose Level layer
  819.   #--------------------------------------------------------------------------    
  820.   def dispose_lv_sprite
  821.     return if @lv_sprite == nil
  822.     @lv_sprite.bitmap.dispose
  823.     @lv_sprite.dispose
  824.   end
  825.   #--------------------------------------------------------------------------
  826.   # ▼ Dispose hp mp gráfico
  827.   #--------------------------------------------------------------------------    
  828.   def dispose_word
  829.     return if @word == nil
  830.     @word.bitmap.dispose
  831.     @word.dispose
  832.   end
  833.   #--------------------------------------------------------------------------
  834.   # ▼ Dispose número del nivel
  835.   #--------------------------------------------------------------------------    
  836.   def dispose_level_number
  837.     return if @lv_number == nil
  838.     @lv_number.bitmap.dispose
  839.     @lv_number.dispose
  840.   end
  841.   #--------------------------------------------------------------------------
  842.   # ▼ Dispose del nombre
  843.   #--------------------------------------------------------------------------    
  844.   def dispose_name
  845.    return if @name == nil
  846.    @name.bitmap.dispose
  847.    @name.dispose
  848.   end
  849.   #--------------------------------------------------------------------------
  850.   # ▼ Dispose número hp
  851.   #--------------------------------------------------------------------------    
  852.   def dispose_hp_number
  853.     return if @hp_number == nil
  854.     @hp_number.bitmap.dispose
  855.     @hp_number.dispose
  856.   end
  857.   #--------------------------------------------------------------------------
  858.   # ▼ Dispose número mp
  859.   #--------------------------------------------------------------------------  
  860.   def dispose_mp_number
  861.     return if @mp_number == nil
  862.     @mp_number.bitmap.dispose
  863.     @mp_number.dispose
  864.   end
  865.   #--------------------------------------------------------------------------
  866.   # ▼ Dispose del layout del oro
  867.   #--------------------------------------------------------------------------    
  868.   def dispose_gold_layout
  869.     return if @gold_layout == nil
  870.     @gold_layout.bitmap.dispose
  871.     @gold_layout.dispose
  872.   end
  873.   #--------------------------------------------------------------------------
  874.   # ▼ Dispose número del oro
  875.   #--------------------------------------------------------------------------    
  876.   def dispose_gold_number
  877.     return if @gold_number == nil
  878.     @gold_number.bitmap.dispose
  879.     @gold_number.dispose
  880.     end
  881.   end
  882. end
  883.  
  884. #===============================================================================
  885. #
  886. #                     ▼ Fin del mundo, acá se acaba todo ▼
  887. #
  888. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment