
class Sprite_PinBallLine < Sprite_Base

  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport, x , y , width ,height , sign)
    super(viewport)
    @x = x
    @y = y
    @width = width
    @height = height
    @cw = 0
    @ch = 0
    @sign = sign
    set_ball_bitmap
#~     update_src_rect
    update
  end

  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    update_position
  end

  
  
  #--------------------------------------------------------------------------
  # ● ボールのビットマップを設定
  #--------------------------------------------------------------------------
  def set_ball_bitmap
    self.bitmap = make_Bitmap

  end
  
  def make_Bitmap
    bitmap = Bitmap.new(@width + 1 , @height + 1) 
    color = Color.new(50,100,180)
    for i in 0 .. @width
      if @sign > 0
        bitmap.set_pixel(i, i *  @height / @width, color)
      else
        bitmap.set_pixel(i, @height - i  * @height / @width, color)
      end  
      
    end
    return bitmap
  end  
#~   #--------------------------------------------------------------------------
#~   # ● 転送元矩形の更新
#~   #--------------------------------------------------------------------------
#~   def update_src_rect
#~     index = @character_index
#~     pattern = 0 
#~     sx = (@ball_index % 4 * 3 + pattern) * @cw
#~     sy = (@ball_index / 4 * 4 ) * @ch
#~     self.src_rect.set(sx, sy, @cw , @ch)
#~   end
  #--------------------------------------------------------------------------
  # ● 位置の更新
  #--------------------------------------------------------------------------
  def update_position
    self.x = @x 
    self.y = @y 
    self.z = 300
  end



end
