Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Sprite_HUD
- #------------------------------------------------------------------------------
- # Autor: Valentine
- #==============================================================================
- #** HUD Modificada
- #==============================================================================
- # Modificado por: Senbonzakura, LeonM²
- #==============================================================================
- class Sprite_HUD < Sprite
- attr_accessor :exp_sprite
- def initialize
- super
- self.bitmap = Bitmap.new(600, 600) # Tamanho da tela da HUD
- self.x = 240 # Posição X da HUD
- self.y = 399 # POsição Y da HUD
- self.z = 0 # Profundidade da HUD
- self.bitmap.font.size = 18 # Tamanho da fonte
- self.bitmap.font.bold = true # Fonte c/ Bold ou não
- @back = Cache.system('HUD') # Imagem da Barra de HUD
- @HP_bar = Cache.system('Hp_Bar') # Imagem da Barra de HP
- @MP_bar = Cache.system('Mp_Bar') # Imagem da Barra de MP
- @XP_bar = Cache.system('Xp_Bar') # Imagem da Barra de EXP
- create_exp_bar
- create_hp_mp_bars
- refresh
- end
- def dispose
- super
- @hp_sprite.bitmap.dispose
- @hp_sprite.dispose
- @mp_sprite.bitmap.dispose
- @mp_sprite.dispose
- @exp_sprite.bitmap.dispose
- @exp_sprite.dispose
- end
- def create_hp_mp_bars
- #HPBAR
- @hp_sprite = Sprite2.new
- @hp_sprite.bitmap = @HP_bar
- @original_y = self.y + 6
- @hp_sprite.x = self.x + 29
- @hp_sprite.y = @original_y
- @hp_sprite.dragable = false
- @hp_sprite.z = self.z + 1
- #MP BAR
- @mp_sprite = Sprite2.new
- @mp_sprite.bitmap = @MP_bar
- @mp_sprite.x = self.x + 141
- @mp_sprite.y = @original_y
- @mp_sprite.dragable = false
- @mp_sprite.z = self.z + 1
- end
- def create_exp_bar
- @exp_sprite = Sprite2.new
- @exp_sprite.bitmap = @XP_bar
- @exp_sprite.x = self.x + 156
- @exp_y = self.y + 13
- @exp_sprite.y = @exp_y
- @exp_sprite.dragable = false
- @exp_sprite.z = self.z + 1
- end
- def refresh
- draw_background
- draw_hp_bar
- draw_mp_bar
- draw_exp_bar
- draw_level
- end
- def draw_background
- self.bitmap.clear
- rect = Rect.new(0, 0, 640, 480) # Tamanho da tela da em aparece todos itens da hud
- self.bitmap.blt(7, 0, @back, rect)
- end
- def draw_hp_bar
- percentage = @HP_bar.height * $game_actors[1].hp / $game_actors[1].mhp
- @hp_sprite.y = @original_y + (@HP_bar.height - percentage)
- @hp_sprite.src_rect.y = (percentage - @HP_bar.height).abs
- end
- def draw_mp_bar
- percentage = @MP_bar.height * $game_actors[1].mp / $game_actors[1].mmp
- @mp_sprite.y = @original_y + (@MP_bar.height - percentage)
- @mp_sprite.src_rect.y = (percentage - @MP_bar.height).abs
- end
- def draw_exp_bar
- percentage = @XP_bar.height * $game_actors[1].now_exp / $game_actors[1].next_exp
- @exp_sprite.y = @exp_y + (@XP_bar.height - percentage)
- @exp_sprite.src_rect.y = (percentage - @XP_bar.height).abs
- end
- def draw_level
- rect = Rect.new(0, 600, 29, 30)
- self.bitmap.blt(0, 77, @back, rect)
- self.bitmap.draw_text(600, 10, 30, 18, $game_actors[1].level, 1)
- end
- def update
- super
- @exp_sprite.update
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement