Advertisement
LeonMMS

Untitled

Aug 25th, 2019
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # ** Sprite_HUD
  3. #------------------------------------------------------------------------------
  4. #  Autor: Valentine
  5. #==============================================================================
  6. #** HUD Modificada
  7. #==============================================================================
  8. # Modificado por: Senbonzakura, LeonM²
  9. #==============================================================================
  10.  
  11. class Sprite_HUD < Sprite
  12.   attr_accessor :exp_sprite
  13.  
  14.   def initialize
  15.     super
  16.     self.bitmap = Bitmap.new(600, 600)    # Tamanho da tela da HUD
  17.     self.x = 240                          # Posição X da HUD
  18.     self.y = 399                          # POsição Y da HUD    
  19.     self.z = 0                            # Profundidade da HUD
  20.     self.bitmap.font.size = 18            # Tamanho da fonte
  21.     self.bitmap.font.bold = true          # Fonte c/ Bold ou não
  22.     @back = Cache.system('HUD')           # Imagem da Barra de HUD
  23.     @HP_bar = Cache.system('Hp_Bar')      # Imagem da Barra de HP
  24.     @MP_bar = Cache.system('Mp_Bar')      # Imagem da Barra de MP
  25.     @XP_bar = Cache.system('Xp_Bar')      # Imagem da Barra de EXP
  26.     create_exp_bar
  27.     create_hp_mp_bars
  28.     refresh
  29.   end
  30.  
  31.   def dispose
  32.     super
  33.     @hp_sprite.bitmap.dispose
  34.     @hp_sprite.dispose
  35.     @mp_sprite.bitmap.dispose
  36.     @mp_sprite.dispose
  37.     @exp_sprite.bitmap.dispose
  38.     @exp_sprite.dispose
  39.   end
  40.   def create_hp_mp_bars
  41.     #HPBAR
  42.     @hp_sprite = Sprite2.new
  43.     @hp_sprite.bitmap = @HP_bar
  44.     @original_y = self.y + 6
  45.     @hp_sprite.x = self.x + 29
  46.     @hp_sprite.y = @original_y
  47.     @hp_sprite.dragable = false
  48.     @hp_sprite.z = self.z + 1
  49.     #MP BAR
  50.     @mp_sprite = Sprite2.new
  51.     @mp_sprite.bitmap = @MP_bar
  52.     @mp_sprite.x = self.x + 141
  53.     @mp_sprite.y = @original_y
  54.     @mp_sprite.dragable = false
  55.     @mp_sprite.z = self.z + 1
  56.   end
  57.   def create_exp_bar
  58.         @exp_sprite = Sprite2.new
  59.         @exp_sprite.bitmap = @XP_bar
  60.         @exp_sprite.x = self.x + 156    
  61.     @exp_y = self.y + 13
  62.     @exp_sprite.y = @exp_y
  63.         @exp_sprite.dragable = false
  64.         @exp_sprite.z = self.z + 1
  65.    
  66.   end
  67.  
  68.   def refresh
  69.     draw_background
  70.     draw_hp_bar
  71.     draw_mp_bar
  72.     draw_exp_bar
  73.     draw_level
  74.   end
  75.  
  76.   def draw_background
  77.     self.bitmap.clear
  78.     rect = Rect.new(0, 0, 640, 480)       # Tamanho da tela da em aparece todos itens da hud
  79.     self.bitmap.blt(7, 0, @back, rect)
  80.   end
  81.  
  82.   def draw_hp_bar
  83.     percentage = @HP_bar.height * $game_actors[1].hp / $game_actors[1].mhp
  84.     @hp_sprite.y = @original_y + (@HP_bar.height - percentage)
  85.     @hp_sprite.src_rect.y = (percentage - @HP_bar.height).abs
  86.   end
  87.  
  88.   def draw_mp_bar
  89.     percentage = @MP_bar.height * $game_actors[1].mp / $game_actors[1].mmp
  90.     @mp_sprite.y = @original_y + (@MP_bar.height - percentage)
  91.     @mp_sprite.src_rect.y = (percentage - @MP_bar.height).abs    
  92.   end
  93.  
  94.   def draw_exp_bar
  95.     percentage = @XP_bar.height * $game_actors[1].now_exp / $game_actors[1].next_exp
  96.     @exp_sprite.y = @exp_y + (@XP_bar.height - percentage)
  97.     @exp_sprite.src_rect.y = (percentage - @XP_bar.height).abs
  98.   end
  99.  
  100.   def draw_level
  101.     rect = Rect.new(0, 600, 29, 30)
  102.     self.bitmap.blt(0, 77, @back, rect)
  103.     self.bitmap.draw_text(600, 10, 30, 18, $game_actors[1].level, 1)
  104.   end
  105.  
  106.   def update
  107.     super
  108.     @exp_sprite.update
  109.   end
  110.  
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement