class HUD < Sprite
#Inicia
def initialize(view)
super(view)
#Cria as cores
@ch1 = Color.new(50,0,0)
@ch2 = Color.new(222,26,50)
@cm1 = Color.new(50,60,60)
@cm2 = Color.new(0,240,50)
@back = Color.new(0,0,0)
@back2 = Color.new(240,240,80)
#Cria o Bitmap
self.bitmap = Bitmap.new(200,200)
self.bitmap.font.name = "UmePlus Gothic"
self.bitmap.font.size = 20
self.z = 300
update
end
#Atualiza
def update
super
#Apaga o conteudo
self.bitmap.clear
#Cria a barra de HP
hp = $game_actors[1].hp
maxhp = $game_actors[1].maxhp
wb = 116 * hp / maxhp
self.bitmap.fill_rect(10, 10, 120, 10, @back)
self.bitmap.fill_rect(11, 11, 118, 8, @back2)
self.bitmap.fill_rect(12, 12, 116, 6, @back)
self.bitmap.gradient_fill_rect(12, 12, wb, 6, @ch1, @ch2)
self.bitmap.draw_text(60, 0, 200, 24, "HP")
#Cria a barra de MP
mp = $game_actors[1].mp
maxmp = $game_actors[1].maxmp
wb = 116 * mp / maxmp
self.bitmap.fill_rect(10, 30, 120, 10, @back)
self.bitmap.fill_rect(11, 31, 118, 8, @back2)
self.bitmap.fill_rect(12, 32, 116, 6, @back)
self.bitmap.gradient_fill_rect(12, 32, wb, 6, @cm1, @cm2)
self.bitmap.draw_text(60, 20, 200, 24, "MP")
end
def dispose
self.bitmap.dispose
super
end
end
#Instala o HUD
class Spriteset_Map
alias :or_initialize :initialize
def initialize
@hud = HUD.new(@viewport2)
or_initialize
end
alias :or_update :update
def update
@hud.update
or_update
end
alias :or_dispose :dispose
def dispose
@hud.dispose
or_dispose
end
end