lib/minigl/game_object.rb
def animate_once(indices, interval)
      if @animate_once_control == 2
        return if indices == @animate_once_indices && interval == @animate_once_interval
        @animate_once_control = 0
      end

      unless @animate_once_control == 1
        @anim_counter = 0
        @img_index = indices[0]
        @index_index = 0
        @animate_once_indices = indices
        @animate_once_interval = interval
        @animate_once_control = 1
        return
      end

      @anim_counter += 1
      return unless @anim_counter >= interval

      @index_index += 1
      @img_index = indices[@index_index]
      @anim_counter = 0
      @animate_once_control = 2 if @index_index == indices.length - 1
    end
def animate_once(indices, interval)
      if @animate_once_control == 2
        return if indices == @animate_once_indices && interval == @animate_once_interval
        @animate_once_control = 0
      end

      unless @animate_once_control == 1
        @anim_counter = 0
        @img_index = indices[0]
        @index_index = 0
        @animate_once_indices = indices
        @animate_once_interval = interval
        @animate_once_control = 1
        return
      end

      @anim_counter += 1
      return unless @anim_counter >= interval

      @index_index += 1
      @img_index = indices[@index_index]
      @anim_counter = 0
      @animate_once_control = 2 if @index_index == indices.length - 1
    end
Causes the sprite to animate through the +indices+ array exactly once,
 so that the animation stops once it reaches the last index in the array.
 Subsequent calls with the same parameters will have no effect, but if
 the index or interval changes, or if +set_animation+ is called, then a
 new animation cycle will begin.

 Parameters:
 [indices] The sequence of image indices used in the animation. See
           +animate+ for details.
 [interval] The amount of frames between each change in the image index.
            See +animate+ for details.