#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Constant Variables
#--------------------------------------------------------------------------
BAR_LENGTH = 32
BAR_HEIGHT = 6
OVER_PLAYER = true
OPACITY = 128
#--------------------------------------------------------------------------
# * Constant Variables
#--------------------------------------------------------------------------
attr_accessor :hpsp_visible
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias_method :ismy_hpsphud_scene_map_main, :main
alias_method :ismy_hpsphud_scene_map_update, :update
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# By default the HUD is visible.
@hpsp_visible = true
# Create are sprite and its bitmap as well as adjusting the z to always
# visible.
@hpsp_bar = Sprite.new
@hpsp_bar.bitmap = Bitmap.new(BAR_LENGTH + 2, BAR_HEIGHT * 2 + 3)
@hpsp_bar.opacity = OPACITY
@hpsp_bar.z = 999
# Top Bar
@hpsp_bar.bitmap.fill_rect(0, 0,
BAR_LENGTH + 2, 1, Color.new(0, 0, 0))
# Left Bar
@hpsp_bar.bitmap.fill_rect(0, 0,
1, BAR_HEIGHT * 2 + 3, Color.new(0, 0, 0))
# Bottom Bar
@hpsp_bar.bitmap.fill_rect(0, BAR_HEIGHT * 2 + 2,
BAR_LENGTH + 2, 1, Color.new(0, 0, 0))
# Right Bar
@hpsp_bar.bitmap.fill_rect(BAR_LENGTH + 1, 0,
1, BAR_HEIGHT * 2 + 3, Color.new(0, 0, 0))
# Draw separating line.
@hpsp_bar.bitmap.fill_rect(0, BAR_HEIGHT + 1,
BAR_LENGTH + 2, 1, Color.new(0, 0, 0))
# Call the old code.
ismy_hpsphud_scene_map_main
# Dispose of our resources.
@hpsp_bar.bitmap.dispose unless @hpsp_bar.bitmap.disposed?
@hpsp_bar.dispose unless @hpsp_bar.disposed?
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Decide whether or not the thing should be seen.
@hpsp_bar.visible = @hpsp_visible
# Only update and or redraw if its visible.
if @hpsp_bar.visible
if OVER_PLAYER
# Draw the bats above the player.
@hpsp_bar.x, @hpsp_bar.y =
($game_player.real_x / 4 + 16) - (BAR_LENGTH / 2),
$game_player.real_y / 4 - 32
else
# Draw the bars below the player.
@hpsp_bar.x, @hpsp_bar.y =
($game_player.real_x / 4 + 16) - (BAR_LENGTH / 2),
$game_player.real_y / 4 + 32
end
# See if the hp/sp needs to be redrawn.
update_bars
end
# Call the old code.
ismy_hpsphud_scene_map_update
end
#--------------------------------------------------------------------------
# * Update the Bars
#--------------------------------------------------------------------------
def update_bars
# If HP has changed from last time.
if @hp != $game_party.actors.first.hp
@hp = $game_party.actors.first.hp
draw_hp_bar
end
# If SP has changed from the last time.
if @sp != $game_party.actors.first.sp
@sp = $game_party.actors.first.sp
draw_sp_bar
end
end
#--------------------------------------------------------------------------
# * Draw HP Bar
#--------------------------------------------------------------------------
def draw_hp_bar
# Clear out the health portion.
@hpsp_bar.bitmap.fill_rect(1, 1,
BAR_LENGTH, BAR_HEIGHT, Color.new(0, 0, 0, 0))
# Determine the actual amount of pixels to draw.
health = BAR_LENGTH *
($game_party.actors.first.hp / $game_party.actors.first.maxhp.to_f)
# Draw the health bar.
@hpsp_bar.bitmap.fill_rect(1, 1,
health, BAR_HEIGHT, Color.new(200, 0, 0))
end
#--------------------------------------------------------------------------
# * Draw SP Bar
#--------------------------------------------------------------------------
def draw_sp_bar
# Clear out the skill portion.
@hpsp_bar.bitmap.fill_rect(1, BAR_HEIGHT + 2,
BAR_LENGTH, BAR_HEIGHT, Color.new(0, 0, 0, 0))
# Determine the actual amount of pixels to draw.
skill = BAR_LENGTH *
($game_party.actors.first.sp / $game_party.actors.first.maxsp.to_f)
# Draw the skill bar.
@hpsp_bar.bitmap.fill_rect(1, BAR_HEIGHT + 2,
skill, BAR_HEIGHT, Color.new(0, 0, 200))
end
end