#==============================================================================
# ** Bitmap
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# * Animated Sprites Options
#--------------------------------------------------------------------------
Anim_Sprite_Reset_Frames = 8
Anim_Sprite_Frame_Width = 4
Anim_Sprite_Frame_Height = 4
#--------------------------------------------------------------------------
# * Scale Blt
#--------------------------------------------------------------------------
def scale_blt(dest_rect, src_bitmap,
src_rect = Rect.new(0, 0, src_bitmap.width, src_bitmap.height), opacity = 255)
w, h = src_rect.width, src_rect.height
scale = [w / dest_rect.width.to_f, h / dest_rect.height.to_f].max
ow, oh = (w / scale).to_i, (h / scale).to_i
ox, oy = (dest_rect.width - ow) / 2, (dest_rect.height - oh) / 2
stretch_blt(Rect.new(ox + dest_rect.x, oy + dest_rect.y, ow, oh),
src_bitmap, src_rect )
end
#--------------------------------------------------------------------------
# * Draw Animated Sprite
#--------------------------------------------------------------------------
def draw_anim_sprite(x, y, w, h, name, hue, stance = 0)
# Gets Frame
frame = (Graphics.frame_count / Anim_Sprite_Reset_Frames) %
Anim_Sprite_Frame_Width
# Draw Sprite
draw_sprite(x, y, w, h, name, hue, stance, frame)
end
#--------------------------------------------------------------------------
# * Draw Sprite
#--------------------------------------------------------------------------
def draw_sprite(x, y, w, h, name, hue, stance = 0, frame = 0)
# Gets Bitmap
bitmap = RPG::Cache.character(name, hue)
# Bitmap Division
cw = bitmap.width / Anim_Sprite_Frame_Width
ch = bitmap.height / Anim_Sprite_Frame_Height
# Gets Animation Offsets
x_off, y_off = cw * frame, ch * stance
# Clears Area
self.fill_rect(Rect.new(x, y, w, h), Color.new(0, 0, 0, 0))
# Draws Bitmap
self.scale_blt(Rect.new(x, y, w, h), bitmap,
Rect.new(x_off, y_off, cw, ch))
end