l0rdph0enix
Member
Ok so I have a few request here.
I have this hud script that looks at a variable and takes 2 pictures (1 being the base and the other the fill) and draws the fill picture depending on how much the value of the variable is between 1 and 100.
I'd rather it be scripted on drawing the bars instead of using pictures.
Also I'd like once that's done, a version of this script be done for VX too please.
Thanks in advance.
I have this hud script that looks at a variable and takes 2 pictures (1 being the base and the other the fill) and draws the fill picture depending on how much the value of the variable is between 1 and 100.
Code:
#==============================================================================
# Hunger_Hud
#------------------------------------------------------------------------------
# By: L0rdPh0enix
# Helped by: Khmp, Gando
# 5/4/2008
#------------------------------------------------------------------------------
#==============================================================================
HUD_SWITCH = 2
Variablehunger = 22
class Hunger_Hud < Window_Base
Max_Hunger = 100
Hunger_Bar = 'Hunger_100'
Hunger_Empty = 'Hunger_0'
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize
super(138, 0, 96, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 200
self.visible = false
@hunger_bar = Bitmap.new('Graphics/Pictures/' + Hunger_Bar)
@empty_bar = Bitmap.new('Graphics/Pictures/' + Hunger_Empty)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
reset_variables
# How full are we?
percent = [@variablehunger / Max_Hunger.to_f, 1.0].min
bar_width = (@hunger_bar.width * percent).to_i
# First clear the bar's position. Draw the old bar first
self.contents.blt(1, 1, @empty_bar,
Rect.new(0, 0, @empty_bar.width, @empty_bar.height))
# Now draw the bar.
self.contents.blt(1, 1, @hunger_bar,
Rect.new(0, 0, bar_width, @hunger_bar.height))
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super()
@hunger_bar.dispose unless @hunger_bar.disposed?
@empty_bar.dispose unless @empty_bar.disposed?
end
def reset_variables
@variablehunger = $game_variables[Variablehunger]
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
super
refresh
end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
alias hungerhud_main main
alias hungerhud_update update
def main
@hungerhud = Hunger_Hud.new
hungerhud_main
@hungerhud.dispose
end
def update
if $game_switches[HUD_SWITCH]
@hungerhud.visible = true
else
@hungerhud.visible = false
end
@hungerhud.update
hungerhud_update
end
end
I'd rather it be scripted on drawing the bars instead of using pictures.
Also I'd like once that's done, a version of this script be done for VX too please.
Thanks in advance.