Module: AuthorEngine::Part::Common

Included in:
Game
Defined in:
lib/author_engine/game/common/parts/common.rb

Instance Method Summary collapse

Instance Method Details

#distance(x1, y1, x2, y2) ⇒ Object



23
24
25
26
27
28
# 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

#fpsObject

returns frames per seconds



15
16
17
18
19
20
21
# 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

#heightObject

returns display height



10
11
12
# File 'lib/author_engine/game/common/parts/common.rb', line 10

def height
  128
end

#levelsObject



30
31
32
# File 'lib/author_engine/game/common/parts/common.rb', line 30

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

#millisecondsObject

returns number of milliseconds since game started



35
36
37
38
39
40
41
42
# 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

#widthObject

returns display width



5
6
7
# File 'lib/author_engine/game/common/parts/common.rb', line 5

def width
  128
end