# File gglib/image.rb, line 42
  def draw(x,y,z)
    if @loop
      @animObj[(Gosu::milliseconds / @speed % @animObj.size)].draw(x,y,z)  #looping mode
      return true #signifies that the animation is still playing
    else  
      if not @started
        start=(Gosu::milliseconds / @speed % @animObj.size)
        @started=true
        @map=[]
        i=0
        start.upto(@animObj.size-1) { |index|
          @map[index]=i
          i+=1
        }
        if start-1>=0
          0.upto(start-1) { |index|
            @map[index]=i
            i+=1
          }
        end
      end
      index=@map[(Gosu::milliseconds / @speed % @animObj.size)]
      if not @done and index < @animObj.size - 1 #single play mode
        @animObj[index].draw(x,y,z)
        return true #singifies that the animation is still playing
      else
        @done=true
        @animObj[@animObj.size - 1].draw(x,y,z)
        return false #signifies that the animation is done. The last frame will be played continueuosly. The caller can take further action 
      end
    end
  end