Sha256: f378a19d415a7f6f350d7a81c3fd08622c136a789a97d266fff73e315b028096

Contents?: true

Size: 934 Bytes

Versions: 3

Compression:

Stored size: 934 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

      def levels
        @authorengine_levels ? @authorengine_levels : AuthorEngine::GameRunner.instance.levels
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
author_engine-0.9.0 lib/author_engine/game/common/parts/common.rb
author_engine-0.8.0 lib/author_engine/game/common/parts/common.rb
author_engine-0.7.0 lib/author_engine/game/common/parts/common.rb