# four images of a cat running up and down
# and can download from http://emiller.posterous.com/ruby-shoes-toolkit-nested-anim

Shoes.app do
  @down1 = image('images/down_1.png')
  @down2 = image('images/down_2.png')
  @up1 = image('images/up_1.png')
  @up2 = image('images/up_2.png')
  @down1.hide
  @down2.hide
  @up1.hide
  @up2.hide

  x = 50
  y = 50
  direction = 1

  animate(10) do

    y += (direction * 2)

    if y > 300 then 
      direction = -1 
      @down1.hide
      @down2.hide
      @up1.show
      @up2.hide
    end
    if y < 10 then 
      direction = 1 
      @down1.show
      @down2.hide
      @up1.hide
      @up2.hide
    end

    if direction == 1 then
      @down1.move(x,y)
      @down2.move(x,y)
    else
      @up1.move(x,y)
      @up2.move(x,y)
    end

    animate(1) do 
      if direction == 1 then
        @down1.toggle
        @down2.toggle
      else
        @up1.toggle
        @up2.toggle
      end
    end

  end
end