class Sprite_DarkLampAround < Sprite
  attr_accessor :type 
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport,character,c_width,c_height,color,type)
    super(viewport)
    @character = character
    @c_width = c_width
    @c_height = c_height
    @px = 0
    @py = 0
    @type = type
    @color = color
    @c_ratio = 1.0
    @edge_a = 3
      
    create_bitmap
    update
  end   
  #--------------------------------------------------------------------------
  # ● スプライトの作成
  #--------------------------------------------------------------------------
  def create_bitmap
    self.bitmap = set_bitmap
    self.bitmap.fill_rect(self.bitmap.rect , @color) 


  end    
  
  def set_bitmap # type 0で上 1で下,2で左 3de右
    if @type == 0 || @type == 1
      width = Graphics.width * 2
      height = Graphics.height
    else
      width = Graphics.width 
      height = Graphics.height * 2  
    end  
    Bitmap.new(width.floor , height.floor )
  end  
  def dispose
    bitmap.dispose if bitmap
    super
  end   
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update_psprite_info(c_width,c_height,c_ratio)
    @c_width = c_width
    @c_height = c_height  
    @c_ratio = c_ratio
  end  
  

  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
#~     update_bitmap
#~     update_timer
#~     update_radius
    
    update_position
#~     update_visibility
  end   
  #--------------------------------------------------------------------------
  # ● 位置の更新
  #--------------------------------------------------------------------------
  def update_position
    self.ox = 0
    self.oy = 0
    @px = (@character.screen_x )
    @py = (@character.screen_y - 12)
    tc_height = @c_ratio * @c_height
    tc_width = @c_ratio * @c_width
    tpx = @px
    tpy = @py
    tedge_a = @c_ratio * @edge_a
    width = bitmap.width
    height = bitmap.height
    case @type
    when 0
      self.x = @px - width / 2
      self.y = @py - tc_height / 2 - height + tedge_a
    when 1
      self.x = @px - width / 2
      self.y = @py + tc_height / 2 - tedge_a  
    when 2
      self.x = @px - tc_width / 2 - width + tedge_a
      self.y = @py - tc_height / 2         
    when 3
      self.x = @px + tc_width / 2 - tedge_a
      self.y = @py - tc_height / 2      
    end  
    

    self.z = 1
  end    
  
end  