Sha256: c4d4d85ab299fc6a0e79f8224a2cd4a9863b050f6c61051b444abfe5a798ead1

Contents?: true

Size: 820 Bytes

Versions: 2

Compression:

Stored size: 820 Bytes

Contents

class AuthorEngine
  class Part
    module Common
      # returns display width
      def width
        128
      end

      # returns display height
      def height
        128
      end

      # returns frames per seconds
      def fps
        if RUBY_ENGINE == "opal"
          AuthorEngine::GameRunner.instance.fps
        else
          Gosu.fps
        end
      end

      def distance(x1, y1, x2, y2)
        dx = x2 - x1
        dy = y2 - y1

        Math.sqrt(dx * dx + dy * dy)
      end

      # returns number of milliseconds since game started
      def milliseconds
        if RUBY_ENGINE == "opal"
          @__initial_milliseconds ||= `performance.now()`
          (`performance.now()` - @__initial_milliseconds).round(3)
        else
          Gosu.milliseconds
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
author_engine-0.6.1 lib/author_engine/game/common/parts/common.rb
author_engine-0.6.0 lib/author_engine/game/common/parts/common.rb