#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Constant Variables
#--------------------------------------------------------------------------
HEART_DRAW_X = 8
HEART_DRAW_Y = 8
HEART_BITMAP = "./graphics/pictures/heart.png"
HEART_SPACES = 3
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias_method :hvdr_hearts_spriteset_map_create_viewports, :create_viewports
alias_method :hvdr_hearts_spriteset_map_update, :update
alias_method :hvdr_hearts_spriteset_map_update_viewports, :update_viewports
#--------------------------------------------------------------------------
# * Create Viewport
#--------------------------------------------------------------------------
def create_viewports
# Call the old code.
hvdr_hearts_spriteset_map_create_viewports
# Create a new viewport for our hearts_sprite to use.
@viewport4 = Viewport.new(0, 0, 544, 50)
@viewport4.z = 150 # Should draw over everything.
# Create the hearts_sprite which will hold the bitmap drawing surface.
@hearts_sprite = Sprite_Base.new(@viewport4)
@hearts_sprite.bitmap = Bitmap.new(544, 50)
# The heart bitmap.
@heart_bitmap = Bitmap.new(HEART_BITMAP)
end
#--------------------------------------------------------------------------
# * Draw Hearts
#--------------------------------------------------------------------------
def draw_hearts(hearts)
# If the amount of hearts hasn't changed return.
return if hearts == @hearts
# Initialize
x, y, @hearts = HEART_DRAW_X, HEART_DRAW_Y, hearts
# Clear the bitmap so we are drawing on a clear slate.
@hearts_sprite.bitmap.clear
# Draw the hearts
for i in 0...@hearts
# Draw the heart onto the sprite.
@hearts_sprite.bitmap.blt(x, y, @heart_bitmap,
Rect.new(0,0,@heart_bitmap.width, @heart_bitmap.height))
# Increment x by the width of the bitmap plus the amount of pixel spacing.
x += (@heart_bitmap.width + HEART_SPACES)
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Call the old code
hvdr_hearts_spriteset_map_update
# Draw me some hearts
draw_hearts(6)
end
#--------------------------------------------------------------------------
# * Update Viewport
#--------------------------------------------------------------------------
def update_viewports
# Call the old code
hvdr_hearts_spriteset_map_update_viewports
# update our
@viewport4.update
end
end