class Ghost
  attr_reader :x, :y, :vx, :vy

  def initialize(image, x, y, vx, vy)
    @image = image
    @x, @y = x, y
    @vx = vx
    @vy = vy
  end

  def draw
    if @vx < 100 then
      @image.draw_rot(@x, @y+@vx, 0, 25 * Math.sin(Gosu::milliseconds / 133.7))       
    end  
    if @vx == 100 && @vy > 0
      @image.draw_rot(@x, @y+@vy-@vx+100, 0, 25 * Math.sin(Gosu::milliseconds / 133.7))               
    end 
    if @vx == 100 && @vy == 0
      @vx = 0
      @vy = 100
    end        
  end   
  
  def update
    if @vx < 100 then      
      @vx+=2   #go down     
    end  
    if @vx == 100 && @vy > 0
      
      @vy-=2  #go up          
    end 
    if @vx == 100 && @vy == 0
      @vx = 0
      @vy = 100
    end
  end      
end    
  

  

