module AuthorEngine::Part::Common

Public Instance Methods

distance(x1, y1, x2, y2) click to toggle source
# File lib/author_engine/game/common/parts/common.rb, line 23
def distance(x1, y1, x2, y2)
  dx = x2 - x1
  dy = y2 - y1

  Math.sqrt(dx * dx + dy * dy)
end
fps() click to toggle source

returns frames per seconds

# File lib/author_engine/game/common/parts/common.rb, line 15
def fps
  if RUBY_ENGINE == "opal"
    AuthorEngine::GameRunner.instance.fps
  else
    Gosu.fps
  end
end
height() click to toggle source

returns display height

# File lib/author_engine/game/common/parts/common.rb, line 10
def height
  128
end
levels() click to toggle source
# File lib/author_engine/game/common/parts/common.rb, line 30
def levels
  @authorengine_levels ? @authorengine_levels : AuthorEngine::GameRunner.instance.levels
end
milliseconds() click to toggle source

returns number of milliseconds since game started

# File lib/author_engine/game/common/parts/common.rb, line 35
def milliseconds
  if RUBY_ENGINE == "opal"
    @__initial_milliseconds ||= `performance.now()`
    (`performance.now()` - @__initial_milliseconds)
  else
    Gosu.milliseconds
  end
end
width() click to toggle source

returns display width

# File lib/author_engine/game/common/parts/common.rb, line 5
def width
  128
end