Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Sprite_HUD
- #------------------------------------------------------------------------------
- # Autor: Valentine
- #==============================================================================
- class Sprite_HUD < Sprite
- def initialize
- super
- self.bitmap = Bitmap.new(308, 107)
- self.x = 11
- self.y = 9
- self.z = 50
- self.bitmap.font.size = 18
- self.bitmap.font.bold = true
- @back = Cache.system('HUD')
- @bars = Cache.system('HUDBars')
- refresh
- end
- def refresh
- draw_background
- draw_face
- draw_hp_bar
- draw_mp_bar
- draw_exp_bar
- draw_level
- end
- def draw_background
- self.bitmap.clear
- rect = Rect.new(0, 0, 308, 98)
- self.bitmap.blt(7, 0, @back, rect)
- end
- def draw_face
- face = Cache.face($game_actors[1].face_name)
- rect = Rect.new($game_actors[1].face_index % 4 * 96, $game_actors[1].face_index / 4 * 96, 96, 96)
- self.bitmap.blt(8, 1, face, rect)
- end
- def draw_hp_bar
- rect = Rect.new(0, 0, 185 * $game_actors[1].hp / $game_actors[1].mhp, 18)
- self.bitmap.blt(108, 16, @bars, rect)
- self.bitmap.draw_text(117, 16, 25, 18, Vocab::hp_a)
- self.bitmap.draw_text(101, 16, 185, 18, "#{$game_actors[1].hp}/#{$game_actors[1].mhp}", 2)
- end
- def draw_mp_bar
- rect = Rect.new(0, 19, 185 * $game_actors[1].mp / $game_actors[1].mmp, 18)
- self.bitmap.blt(108, 35, @bars, rect)
- self.bitmap.draw_text(117, 35, 25, 18, Vocab::mp_a)
- self.bitmap.draw_text(101, 35, 185, 18, "#{$game_actors[1].mp}/#{$game_actors[1].mmp}", 2)
- end
- def draw_exp_bar
- rect = Rect.new(0, 39, 185 * $game_actors[1].now_exp / $game_actors[1].next_exp, 18)
- exp = $game_actors[1].level >= Configs::MAX_LEVEL ? Vocab::MaxLevel : $game_actors[1].next_exp - $game_actors[1].now_exp
- self.bitmap.blt(108, 55, @bars, rect)
- self.bitmap.draw_text(117, 55, 25, 18, Vocab::Exp)
- self.bitmap.draw_text(101, 55, 185, 18, exp, 2)
- end
- def draw_level
- rect = Rect.new(0, 124, 29, 30)
- self.bitmap.blt(0, 77, @back, rect)
- self.bitmap.draw_text(0, 83, 30, 18, $game_actors[1].level, 1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment