Module: AuthorEngine::Part::Common
- Included in:
- Game
- Defined in:
- lib/author_engine/game/common/parts/common.rb
Instance Method Summary collapse
- #distance(x1, y1, x2, y2) ⇒ Object
-
#fps ⇒ Object
returns frames per seconds.
-
#height ⇒ Object
returns display height.
- #levels ⇒ Object
-
#milliseconds ⇒ Object
returns number of milliseconds since game started.
-
#width ⇒ Object
returns display width.
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 |
#fps ⇒ Object
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 |
#height ⇒ Object
returns display height
10 11 12 |
# File 'lib/author_engine/game/common/parts/common.rb', line 10 def height 128 end |
#levels ⇒ Object
30 31 32 |
# File 'lib/author_engine/game/common/parts/common.rb', line 30 def levels ? : AuthorEngine::GameRunner.instance.levels end |
#milliseconds ⇒ Object
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 |
#width ⇒ Object
returns display width
5 6 7 |
# File 'lib/author_engine/game/common/parts/common.rb', line 5 def width 128 end |