This is my first script posted here, so give me comment or something, ok?
#====================================================================
# Supersimple Head-Up Display
#-----------------------------------------------------------------
# ** Version 1.0
# ** Original by Sthrattoff
#====================================================================
# Description :
# This script will allow you to show a HUD window on your map.
# Instruction :
# Put this script above main
# How to Use?
# To call, use Call Script :
# Call Script : $window = Window_HUD.new(game_party_id(0-3))
# To remove, use this
# Call Script : $window.dispose
# For RMXP - PK : "Add self.contents.font.name and font.size by yourself"
#==============================================
# Modification to Window_Base
#==============================================
class Window_Base < Window
def draw_actor_face(actor, x, y)
bitmap = RPG::Cache.picture(actor.name)
self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 96, 96))
end
def draw_actor_hpbar(actor, x, y, w = 120)
# Defines actor hp and maxhp
vitality = actor.hp
maxvitality = actor.maxhp
# Defines color used on bar
bordercolor = system_color
outercolor = Color.new(220, 10, 0, 255)
midcolor = Color.new(220, 35, 0, 255)
innercolor = Color.new(220, 60, 0, 255)
emptycolor = Color.new(0, 0, 0, 255)
# Defines length of bar
linewidth = (((vitality * 1.0) / maxvitality) * (w - 2))
emptywidth = ((w - 1) - linewidth)
emptyx = ((x + 1) + linewidth)
# Drawing line and border
borderup = Rect.new(x, y, w, 1)
borderleft = Rect.new(x, y + 1, 1, 6)
borderdown = Rect.new(x, y + 7, w, 1)
borderright = Rect.new(x + w - 1, y + 1, 1, 6)
emptyline = Rect.new(x + 1, y + 1, w - 2, 6)
outerline = Rect.new(x + 1, y + 1, linewidth, 6)
midline = Rect.new(x + 2, y + 2, linewidth - 2, 4)
innerline = Rect.new(x + 3, y + 3, linewidth - 4, 2)
# Coloring the bar
self.contents.fill_rect(borderup, bordercolor)
self.contents.fill_rect(borderleft, bordercolor)
self.contents.fill_rect(borderdown, bordercolor)
self.contents.fill_rect(borderright, bordercolor)
self.contents.fill_rect(emptyline, emptycolor)
self.contents.fill_rect(outerline, outercolor)
self.contents.fill_rect(midline, midcolor)
self.contents.fill_rect(innerline, innercolor)
end
def draw_actor_spbar(actor, x, y, w = 200)
# Defines actor sp and maxsp
force = actor.sp
maxforce = actor.maxsp
# Defines color used on bar
bordercolor = system_color
outercolor = Color.new(0, 110, 180, 255)
midcolor = Color.new(0, 135, 180, 255)
innercolor = Color.new(0, 160, 180, 255)
emptycolor = Color.new(0, 0, 0, 255)
# Defines length of bar
linewidth = (((force * 1.0) / maxforce) * (w - 2))
emptywidth = ((w - 1) - linewidth)
emptyx = ((x + 1) + linewidth)
# Drawing line and border
borderup = Rect.new(x, y, w, 1)
borderleft = Rect.new(x, y + 1, 1, 6)
borderdown = Rect.new(x, y + 7, w, 1)
borderright = Rect.new(x + w - 1, y + 1, 1, 6)
emptyline = Rect.new(x + 1, y + 1, w - 2, 6)
outerline = Rect.new(x + 1, y + 1, linewidth, 6)
midline = Rect.new(x + 2, y + 2, linewidth - 2, 4)
innerline = Rect.new(x + 3, y + 3, linewidth - 4, 2)
# Coloring the bar
self.contents.fill_rect(borderup, bordercolor)
self.contents.fill_rect(borderleft, bordercolor)
self.contents.fill_rect(borderdown, bordercolor)
self.contents.fill_rect(borderright, bordercolor)
self.contents.fill_rect(emptyline, emptycolor)
self.contents.fill_rect(outerline, outercolor)
self.contents.fill_rect(midline, midcolor)
self.contents.fill_rect(innerline, innercolor)
end
end
#==============================================
# Window_HUD
#==============================================
class Window_HUD < Window_Base
def initialize(actor)
super(0, 0, 160, 128)
self.contents = Bitmap.new(width - 32, height - 32)
@index = actor
refresh
end
def refresh
self.contents.clear
@actor = $game_party.actors[@index]
draw_actor_face(@actor, 0, 0)
draw_actor_name(@actor, 108, 0)
draw_actor_hpbar(@actor, 108, 32 + 16, 52)
draw_actor_hp(@actor, 108, 32)
draw_actor_spbar(@actor, 108, 64 + 16, 52)
draw_actor_sp(@actor, 108, 64)
draw_actor_level(@actor, 0, 128)
draw_actor_class(@actor, 64, 128)
end
def change
refresh
end
end
Don't forget to post any bugs...