#========================================
# HUD Setup
#--------------------------------------------------------------------------------
SPEDOMETER_VAR = 1 # the variable that controls the spedometer
SPEDOMETER_UNIT = 'mph' # the unit the spedometer measures in
ITEM_VAR = 2 # the variable controling the items.
ITEMS = ['no_item', 'banana_peel', 'coin', 'feather', 'g_shell', 'r_shell', 'lightning', 'mushroom', 'star']
# When the variable equals 0, the no_item picture will be displayed.
# The others will be displayed as the variable goes up in their order.
# If the varaible is 1, the picture will be banana_peel. If it is 2, it will
# be coin; 3 is feather; 4 is g_shell and so on. Just change the variable
# in your event. Remember, don't make it above one less than the number
# of icons you have. Make sure you put all your icons in the icon folder.
#========================================
class Scene_Map
alias hud_main main
alias hud_update update
def main
opacity = 0
@base = Window_Base.new(0, 0, 640, 480)
@base.opacity = opacity
@hud = Hud.new
@hud.opacity = opacity
@sped = Spedometer.new
@sped.opacity = opacity
@item = Get_Item.new
hud_main
@base.dispose
@hud.dispose
@sped.dispose
@item.dispose
end
def update
@base.update
@hud.update
@sped.update
@item.update
hud_update
end
end
#--------------------------------------------------------------------------------
# Spedometer
#--------------------------------------------------------------------------------
class Spedometer < Window_Base
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
update
end
def update
self.contents.clear
var = $game_variables[SPEDOMETER_VAR].to_s
unit = SPEDOMETER_UNIT.to_s
uw = contents.text_size(unit).width
vw = contents.text_size(var).width
sw = contents.text_size(unit + var).width
self.contents.font.color = normal_color
self.contents.draw_text(640-sw-50, 416, vw, 32, var, 0)
self.contents.font.color = system_color
self.contents.draw_text(640-uw-45, 416, 200, 32, unit, 0)
end
end
#--------------------------------------------------------------------------------
# HUD
#--------------------------------------------------------------------------------
class Hud < Window_Base
def initialize
super(0, 0, 800, 600)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
refresh
end
def refresh
self.contents.clear
x = 5
actor = $game_party.actors[0]
self.contents.font.size = 21
self.contents.font.color = normal_color
self.contents.draw_text(x + 55, -10, 100, 32, actor.name)
width = 100
height = 10
draw_slant_bar(x + 25, 20, actor.hp, actor.maxhp, width, height, Color.new(150, 0, 0), Color.new(155, 155, 60))
draw_slant_bar(x + 25, 40, actor.sp, actor.maxsp, width, height, Color.new(0, 0, 150), Color.new(60, 155, 155))
self.contents.font.size = 16
self.contents.font.color = normal_color
self.contents.font.bold = true
self.contents.font.color = actor.hp == 0 ? knockout_color : actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(x + 30, 9, 100, 32, "#{actor.hp}/#{actor.maxhp}", 1)
self.contents.font.color = actor.sp == 0 ? crisis_color : actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
self.contents.draw_text(x + 30, 29, 100, 32, "#{actor.sp}/#{actor.maxsp}", 1)
self.contents.font.color = system_color
self.contents.font.size = 20
self.contents.draw_text(x, 8, 34, 32, $data_system.words.hp)
self.contents.draw_text(x, 28, 54, 32, $data_system.words.sp)
end
end
#--------------------------------------------------------------------------------
# Get item Pop-up
#--------------------------------------------------------------------------------
class Get_Item < Sprite
def initialize
super(Viewport.new(0, 0, 640, 480))
update
end
def update
@pop_up = Sprite.new(super)
i = $game_variables[ITEM_VAR]
item = ITEMS[i]
@pop_up.bitmap = RPG::Cache.icon(item) if item != nil
@pop_up.x = 295
@pop_up.y = 5
end
end
#--------------------------------------------------------------------------------
# Seph's Bars
#--------------------------------------------------------------------------------
class Window_Base < Window
def draw_slant_bar(x, y, min, max, width = 152, height = 6,
bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
for i in 0..height
self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
end
for i in 1..(height - 1)
r = 100 * (height - i) / height + 0 * i / height
g = 100 * (height - i) / height + 0 * i / height
b = 100 * (height - i) / height + 0 * i / height
a = 255 * (height - i) / height + 255 * i / height
self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
end
for i in 1..( (min / max.to_f) * width - 1)
for j in 1..(height - 1)
r = bar_color.red * (width - i) / width + end_color.red * i / width
g = bar_color.green * (width - i) / width + end_color.green * i / width
b = bar_color.blue * (width - i) / width + end_color.blue * i / width
a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
end
end
end
end