marlosgama

HUD Daniel Carvalho

Apr 21st, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.21 KB | None | 0 0
  1. #==============================================================================
  2. # ** Sprite_HUD
  3. #------------------------------------------------------------------------------
  4. #  Autor: Valentine
  5. #==============================================================================
  6.  
  7. class Sprite_HUD < Sprite
  8.  
  9.   def initialize
  10.     super
  11.     self.bitmap = Bitmap.new(308, 107)
  12.     self.x = 11
  13.     self.y = 9
  14.     self.z = 50
  15.     self.bitmap.font.size = 18
  16.     self.bitmap.font.bold = true
  17.     @back = Cache.system('HUD')
  18.     @bars = Cache.system('HUDBars')
  19.     refresh
  20.   end
  21.  
  22.   def refresh
  23.     draw_background
  24.     draw_face
  25.     draw_hp_bar
  26.     draw_mp_bar
  27.     draw_exp_bar
  28.     draw_level
  29.   end
  30.  
  31.   def draw_background
  32.     self.bitmap.clear
  33.     rect = Rect.new(0, 0, 308, 98)
  34.     self.bitmap.blt(7, 0, @back, rect)
  35.   end
  36.  
  37.   def draw_face
  38.     face = Cache.face($game_actors[1].face_name)
  39.     rect = Rect.new($game_actors[1].face_index % 4 * 96, $game_actors[1].face_index / 4 * 96, 96, 96)
  40.     self.bitmap.blt(8, 1, face, rect)
  41.   end
  42.  
  43.   def draw_hp_bar
  44.     rect = Rect.new(0, 0, 185 * $game_actors[1].hp / $game_actors[1].mhp, 18)
  45.     self.bitmap.blt(108, 16, @bars, rect)
  46.     self.bitmap.draw_text(117, 16, 25, 18, Vocab::hp_a)
  47.     self.bitmap.draw_text(101, 16, 185, 18, "#{$game_actors[1].hp}/#{$game_actors[1].mhp}", 2)
  48.   end
  49.  
  50.   def draw_mp_bar
  51.     rect = Rect.new(0, 19, 185 * $game_actors[1].mp / $game_actors[1].mmp, 18)
  52.     self.bitmap.blt(108, 35, @bars, rect)
  53.     self.bitmap.draw_text(117, 35, 25, 18, Vocab::mp_a)
  54.     self.bitmap.draw_text(101, 35, 185, 18, "#{$game_actors[1].mp}/#{$game_actors[1].mmp}", 2)
  55.   end
  56.  
  57.   def draw_exp_bar
  58.     rect = Rect.new(0, 39, 185 * $game_actors[1].now_exp / $game_actors[1].next_exp, 18)
  59.     exp = $game_actors[1].level >= Configs::MAX_LEVEL ? Vocab::MaxLevel : $game_actors[1].next_exp - $game_actors[1].now_exp
  60.     self.bitmap.blt(108, 55, @bars, rect)
  61.     self.bitmap.draw_text(117, 55, 25, 18, Vocab::Exp)
  62.     self.bitmap.draw_text(101, 55, 185, 18, exp, 2)
  63.   end
  64.  
  65.   def draw_level
  66.     rect = Rect.new(0, 124, 29, 30)
  67.     self.bitmap.blt(0, 77, @back, rect)
  68.     self.bitmap.draw_text(0, 83, 30, 18, $game_actors[1].level, 1)
  69.   end
  70.  
  71. end
Advertisement
Add Comment
Please, Sign In to add comment