# File lib/rubygame/clock.rb, line 442
    def tick()

      # how long since the last tick?
      passed = 0
      if @last_tick
        passed += self.class.runtime() - @last_tick
      end

      if @target_frametime
        extra = @target_frametime - passed
        if( extra > 0 )
          passed += self.class.delay( extra, @granularity, @nice )
        end
      end

      if @tick_events
        return (@tick_cache[passed] or 
                 (@tick_cache[passed] =
                  Rubygame::Events::ClockTicked.new( passed ) ))
      else
        return passed
      end

    ensure
      @last_tick = self.class.runtime()
      @ticks += 1

      # Save the frametime for framerate calculation
      @samples.push(passed)
      @samples.shift if @samples.length > @max_samples
    end