Sha256: d29eeeac73d66327817504fbb52f4d103a70fb73959110db46e2b8c429f887b4

Contents?: true

Size: 592 Bytes

Versions: 1

Compression:

Stored size: 592 Bytes

Contents

module Lotu
  class FpsSystem < System

    def initialize(user, opts={})
      super
      default_opts = {
        :ticks_per_update => 10
      }
      opts = default_opts.merge!(opts)
      @accum = 0.0
      @ticks = 0
      @fps = 0.0
      @ticks_per_update = opts[:ticks_per_update]
    end

    def update
      @ticks += 1
      @accum += $lotu.dt
      if @ticks >= @ticks_per_update
        @fps = @ticks/@accum
        @ticks = 0
        @accum = 0.0
      end
    end

    def to_s
      "Ticks per update: #{@ticks_per_update} | FPS: #{format("%.2f",@fps)}"
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lotu-0.1.15 lib/lotu/systems/fps_system.rb