Module: Metro::Game
Defined Under Namespace
Classes: DSL
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#execution_parameters ⇒ Object
The original parameters specified during execution.
-
#window ⇒ Object
readonly
The current game window.
Instance Method Summary collapse
- #authors ⇒ Object
- #bounds ⇒ Object
- #center ⇒ Object
- #contact ⇒ Object
- #controls ⇒ Object
-
#current_scene ⇒ Scene, NilClass
The current scene that is being displayed.
- #debug? ⇒ Boolean
- #dimensions ⇒ Object
- #fetch(name, fallback = nil) ⇒ Object
- #first_scene ⇒ Object
- #fullscreen? ⇒ Boolean
- #height ⇒ Object
- #name ⇒ Object
- #setup(game_configuration) ⇒ Object
-
#start! ⇒ Object
Creates a window and starts the game with the game parameters.
- #website ⇒ Object
- #width ⇒ Object
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
99 100 101 |
# File 'lib/metro/game.rb', line 99 def config @config end |
#execution_parameters ⇒ Object
The original parameters specified during execution. These are the args found on the command-line that are passed in when the game started.
23 24 25 |
# File 'lib/metro/game.rb', line 23 def execution_parameters @execution_parameters ||= [] end |
#window ⇒ Object (readonly)
Returns the current game window.
32 33 34 |
# File 'lib/metro/game.rb', line 32 def window @window end |
Instance Method Details
#authors ⇒ Object
79 80 81 |
# File 'lib/metro/game.rb', line 79 def fetch(:authors) end |
#bounds ⇒ Object
55 56 57 |
# File 'lib/metro/game.rb', line 55 def bounds Units::RectangleBounds.new left: 0, right: width, top: 0, bottom: height end |
#center ⇒ Object
63 64 65 |
# File 'lib/metro/game.rb', line 63 def center Units::Point.at width / 2 , height / 2 end |
#contact ⇒ Object
87 88 89 |
# File 'lib/metro/game.rb', line 87 def contact fetch(:contact) end |
#controls ⇒ Object
91 92 93 |
# File 'lib/metro/game.rb', line 91 def controls config.controls.defined_controls end |
#current_scene ⇒ Scene, NilClass
Returns the current scene that is being displayed. If this is called before the window is being displayed when this will return a nil value.
39 40 41 |
# File 'lib/metro/game.rb', line 39 def current_scene window ? window.scene : nil end |
#debug? ⇒ Boolean
71 72 73 |
# File 'lib/metro/game.rb', line 71 def debug? !!fetch(:debug) end |
#dimensions ⇒ Object
59 60 61 |
# File 'lib/metro/game.rb', line 59 def dimensions Units::Dimensions.of width, height end |
#fetch(name, fallback = nil) ⇒ Object
95 96 97 |
# File 'lib/metro/game.rb', line 95 def fetch(name,fallback = nil) config.send(name) rescue fallback end |
#first_scene ⇒ Object
43 44 45 |
# File 'lib/metro/game.rb', line 43 def first_scene fetch(:first_scene) end |
#fullscreen? ⇒ Boolean
67 68 69 |
# File 'lib/metro/game.rb', line 67 def fullscreen? !!fetch(:fullscreen) end |
#height ⇒ Object
51 52 53 |
# File 'lib/metro/game.rb', line 51 def height fetch(:height,480) end |
#name ⇒ Object
75 76 77 |
# File 'lib/metro/game.rb', line 75 def name fetch(:name) end |
#setup(game_configuration) ⇒ Object
7 8 9 |
# File 'lib/metro/game.rb', line 7 def setup(game_configuration) @config = game_configuration end |
#start! ⇒ Object
Creates a window and starts the game with the game parameters.
14 15 16 17 18 19 |
# File 'lib/metro/game.rb', line 14 def start! @window = Window.new width, height, fullscreen? window. = name window.scene = Scenes.generate(first_scene) window.show end |
#website ⇒ Object
83 84 85 |
# File 'lib/metro/game.rb', line 83 def website fetch(:website,Metro::WEBSITE) end |
#width ⇒ Object
47 48 49 |
# File 'lib/metro/game.rb', line 47 def width fetch(:width,640) end |