Brasil G4mes
Registre-se para ter acesso total à todas as seções do fórum!
Jogue, brinque e o mais importante, divirta-se!

Participe do fórum, é rápido e fácil

Brasil G4mes
Registre-se para ter acesso total à todas as seções do fórum!
Jogue, brinque e o mais importante, divirta-se!
Brasil G4mes
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

HUD

Ir para baixo

HUD Empty HUD

Mensagem por john oliv Qua Jun 23, 2010 10:18 am

HUD simples editavel, pode ou não mostrar o HP/MP de todos os integrantes da equipe.

Levemente editado por mim, instruções de editação no script.

Feito por: VitorJ

Instrções: Cole acima de "main"

Screen:

Spoiler:



Código:
==============================================================================#
# HUD Simples By VitorJ
# Cria uma HUD simples que não despõe de imagen, mas com um design agradavel
# mostrando o HP, MP , EXP, E o grafico do personagen de cada char
# no grupo, ou só do primeiro.
# tem muitas opções para personalizar a seu gosto
#==============================================================================#
# Classes modificadas com esse Script:
# Scene_Map , Game_Actor
#==============================================================================#
module Hud_Edit
e = 135 # (Opcional) Coloque aqui o espaço entre uma hud e outra
HUDX = [0*e,1*e,2*e,3*e] # Posição X Da HUD [char1,char2,char3,char4]
HUDY = [10,10,10,10] # Posição Y Da HUD [char1,char2,char3,char4]
ATT = 1 # Vai atualizar rapido(0) ou lento(1)? (PS: Pode dechar o jogo com lag enquanto atualiza...)
SHOW = true # A HUD vai começar no mapa?
SWITCH = 0 # Switch que mostrara a HUD.
FONTNAME = "Palatino Linotype" # Fonte das Letras
SP = "SP" # Nome do MP
COR_SP = Color.new(0,255,255,200) # Cor da letra do MP
HP = "HP" # Nome do HP
PARTY = true # Vai mostrar a HUD dos outros membros?
FACE_AJUST = -1 # Coloque um ajuste para face do personagen.
# Cor das Barras, coloque [r,g,b,opacity]
C_INI_HP = Color.new(0,100,0,255) #Cor Inicial da barra de HP
C_FIN_HP = Color.new(253,209,77,255) #Cor Final da barra de HP
C_INI_SP = Color.new(67,89,153,255) #Cor Inicial da barra de SP
C_FIN_SP = Color.new(2,58,218,255) #Cor Final da barra de SP
C_INI_BA = Color.new(255,255,255,200) #Cor Inicial da borda
C_FIN_BA = Color.new(160,160,160,200) #Cor Final da borda
BAR_BACK1 = Color.new(255,255,255,100) # Cor inicial do fundo das barras
BAR_BACK2 = Color.new(255,255,255,100) # Cor final do fundo das barras
end
class Simple_Hud_Sprite < Sprite
include Hud_Edit
def initialize(viewport,actor,pchar)
super(viewport)
self.bitmap = Bitmap.new(544, 416)
self.bitmap.font.name = FONTNAME
self.visible = $game_switches[SWITCH]
@actor = actor
@pchar = pchar
start if actor != nil
end
def start
actor = @actor
@hp = actor.hp
@sp = actor.mp
@maxhp = actor.maxhp
@maxsp = actor.maxmp
@name = actor.name
@level = actor.level
@exp = actor.exp
@gold = $game_party.gold.to_s
draw_char
draw_hp
draw_sp
draw_xp
draw_name
#draw_gold
end
def draw_char
actor = @actor
x = HUDX[@pchar]
y = HUDY[@pchar]+8
character_name = @actor.character_name
character_index = @actor.character_index
return if character_name == nil
bitmap = Cache.character(character_name)
sign = character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = character_index
src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch+FACE_AJUST, cw, (ch/2)+(ch/3))
self.bitmap.fill_rect(Rect.new(x, y, cw, ch), Color.new(0,0,0,0))
self.bitmap.blt(x, y, bitmap, src_rect)
end
def draw_name
x = HUDX[@pchar]+8
y = HUDY[@pchar]
end
def draw_hp
x = HUDX[@pchar]+8
y = HUDY[@pchar]
w = 85
self.bitmap.fill_rect(Rect.new(x-3, y-6, w+15, 15), Color.new(0,0,0,0))
draw_gradient(Color.new(0,0,0,255),Color.new(0,0,0,255),w+2,8,x,y)
draw_gradient(C_INI_BA,C_FIN_BA,w,6,x+2,y+1)
draw_gradient(BAR_BACK1,BAR_BACK2,w-2,4,x+4,y+2)
cw = (w-2) * @hp / @maxhp
ch = 4
draw_gradient(C_INI_HP,C_FIN_HP,cw,ch,x+4,y+2)
text = HP
self.bitmap.font.size = 15
size = self.bitmap.text_size(text)
rx = 155 * @hp / @maxhp
draw_text(x-2, y-12,size.width,size.height,text,Color.new(rx+100,0,0,200))
self.bitmap.font.size = 15
text = "[url=http://mastermaker.forumeiros.com/mailto:#{@hp]#{@hp[/url]} / [url=http://mastermaker.forumeiros.com/mailto:#{@maxhp]#{@maxhp[/url]}"
size = self.bitmap.text_size(text)
c = 255 * @hp / @maxhp
draw_text(x+50, y-8,size.width,size.height, text,Color.new(255,c,c,200))
end
def draw_sp
x = HUDX[@pchar]+32
y = HUDY[@pchar]+20
w = 85
self.bitmap.fill_rect(Rect.new(x-3, y-6, w+15, 15), Color.new(255,0,0,0))
draw_gradient(Color.new(0,0,0,255),Color.new(0,0,0,255),w+2,8,x,y)
draw_gradient(C_INI_BA,C_FIN_BA,w,6,x+2,y+1)
draw_gradient(BAR_BACK1,BAR_BACK2,w-2,4,x+4,y+2)
cw = (w-2) * @sp / @maxsp
ch = 4
draw_gradient(C_INI_SP,C_FIN_SP,cw,ch,x+4,y+2)
text = SP
size = self.bitmap.text_size(text)
draw_text(x-2, y-8,size.width,size.height,text,COR_SP)
self.bitmap.font.size = 15
text = "[url=http://mastermaker.forumeiros.com/mailto:#{@sp]#{@sp[/url]} / [url=http://mastermaker.forumeiros.com/mailto:#{@maxsp]#{@maxsp[/url]}"
size = self.bitmap.text_size(text)
self.bitmap.font.size = 15
draw_text(x+50, y-8,size.width,size.height, text,Color.new(255,255,255,200))
end
def draw_xp
x = HUDX[@pchar]
y = HUDY[@pchar]+29
w = 32
c = 5
actor = @actor
self.bitmap.fill_rect(Rect.new(x, y, w, c), Color.new(0,0,0,0))
if actor.next_exp != 0
rate = actor.now_exp.to_f / actor.next_exp
else
rate = 1
end
if @actor.level < 99
cw = (w-2) * rate
else
cw = w-2
end
ch = 5-2
self.bitmap.fill_rect(Rect.new(x, y, w, c), Color.new(0,0,0,255))
self.bitmap.fill_rect(Rect.new(x+1, y+1, w-2, c-2), Color.new(0,0,0,160))
self.bitmap.gradient_fill_rect(x+1,y+1, cw, ch , Color.new(67,153,153,200),Color.new(2,218,218,255) )
self.bitmap.font.size = 15
#text = "Level: [url=http://mastermaker.forumeiros.com/mailto:#{@level]#{@level[/url]}"
#size = self.bitmap.text_size(text)
#draw_text(x, y-8,size.width,size.height, text,Color.new(255,255,255,255))
end
def draw_gradient(cor_ini,cor_fin,width,height,x,y,type=0)
for i in 0..height
self.bitmap.gradient_fill_rect(x+i, y+i, width, 1, cor_ini, cor_fin)
end
end
def draw_text(x,y,width,height,text,color)
self.bitmap.font.color = Color.new(0,0,0,255)
self.bitmap.draw_text(Rect.new(x-1, y,width,height), text)
self.bitmap.draw_text(Rect.new(x+1, y,width,height), text)
self.bitmap.draw_text(Rect.new(x, y-1,width,height), text)
self.bitmap.draw_text(Rect.new(x, y+1,width,height), text)
self.bitmap.font.color = color
self.bitmap.draw_text(Rect.new(x, y,width,height), text)
end
def update(pchar)
if $game_party.members[@pchar] != nil
actor = $game_party.members[@pchar]
else
actor = $game_actors[0]
end
if @actor != actor
@actor = actor
start
end
if @hp != actor.hp or @maxhp != actor.maxhp
@hp = actor.hp
@maxhp = actor.maxhp
draw_hp
end
if @sp != actor.mp or @maxsp != actor.maxmp
@sp = actor.mp
@maxsp = actor.maxmp
draw_sp
end
if @exp != actor.exp or @level != actor.level
@exp = actor.exp
@level = actor.level
draw_xp
end
self.visible = $game_switches[SWITCH]
end
end
class Simple_Hud
def initialize
@viewport = Viewport.new(0, 0, 544, 416)
@viewport.z = 9999
@simple_hud = []
@sprites = []
@psize = $game_party.members.size
if Hud_Edit::PARTY == true
for i in 0...4#$game_party.members.size
actor = $game_actors[0]
actor = $game_party.members[i] if $game_party.members[i] != nil
pchar = i
@simple_hud[i] = Simple_Hud_Sprite.new(@viewport,actor,pchar)
@sprites.push(@simple_hud[i])
end
else
actor = $game_actors[0]
actor = $game_party.members[0] if $game_party.members[0] != nil
pchar = 0
@simple_hud[0] = Simple_Hud_Sprite.new(@viewport,actor,pchar)
@sprites.push(@simple_hud[0])
end
@visible = true
end
def update
if @psize != $game_party.members.size
if Hud_Edit::PARTY == true
for i in [url=http://mastermaker.forumeiros.com/mailto:0...@psize]0...@psize[/url]
@simple_hud[i].visible = false
end
for i in 0...$game_party.members.size
actor = $game_actors[0]
actor = $game_party.members[i] if $game_party.members[i] != nil
pchar = i
@simple_hud[i].update(i)
end
else
actor = $game_actors[0]
actor = $game_party.members[0] if $game_party.members[0] != nil
pchar = 0
@simple_hud[0].update(0)
end
else
if Hud_Edit::PARTY == true
for i in 0...$game_party.members.size
@simple_hud[i].update(i)
end
else
@simple_hud[0].update(0)
end
end
end
def dispose
for sprite in @sprites
next if sprite.nil?
sprite.dispose
end
@sprites = []
end
end
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
class Scene_Map
$hud_started = false if $hud_started == nil
alias simple_hud_main main
def main
@hud = Simple_Hud.new
$game_switches[Hud_Edit::SWITCH] = Hud_Edit::SHOW if not $hud_started
$hud_started = true
simple_hud_main
@hud.dispose
end
alias simple_hud_update update
def update
@hud.update
simple_hud_update
end
end
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
class Game_Actor < Game_Battler
def now_exp
return @exp - @exp_list[@level]
end
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end

john oliv
Membro
Membro

Mensagens Mensagens : 262
Fama Fama : 32

Ir para o topo Ir para baixo

Ir para o topo


 
Permissões neste sub-fórum
Não podes responder a tópicos