Class: Game::Window::Window
- Inherits:
-
Object
- Object
- Game::Window::Window
- Includes:
- MetaTools
- Defined in:
- lib/game/window.rb
Instance Attribute Summary collapse
- #fullscreen(value = nil) ⇒ Object
- #height(value = nil) ⇒ Object
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
- #title(value = nil) ⇒ Object
- #width(value = nil) ⇒ Object
Instance Method Summary collapse
- #add_entity(entity, *args) {|entity_instance| ... } ⇒ Object
- #entities ⇒ Object
-
#init_window ⇒ Object
abstract
Initialize the underlying adapter window.
-
#initialize(options = {}) ⇒ Window
constructor
abstract
Initialize the game window.
Constructor Details
#initialize(options = {}) ⇒ Window
This method is abstract.
Override and call ‘super` after you’ve setup the width, height, and title.
Initialize the game window.
24 25 26 27 28 29 30 |
# File 'lib/game/window.rb', line 24 def initialize(={}) # Complain if @title isn't set? # Complain if @width isn't set? # Complain if height isn't set? init_window @started_at = Time.now end |
Instance Attribute Details
#fullscreen(value = nil) ⇒ Object
51 52 53 54 |
# File 'lib/game/window.rb', line 51 def fullscreen(value=nil) @fullscreen = value unless value.nil? @fullscreen end |
#height(value = nil) ⇒ Object
45 46 47 48 |
# File 'lib/game/window.rb', line 45 def height(value=nil) @height = value unless value.nil? @height end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
19 20 21 |
# File 'lib/game/window.rb', line 19 def started_at @started_at end |
#title(value = nil) ⇒ Object
33 34 35 36 |
# File 'lib/game/window.rb', line 33 def title(value=nil) @title = value unless value.nil? @title end |
#width(value = nil) ⇒ Object
39 40 41 42 |
# File 'lib/game/window.rb', line 39 def width(value=nil) @width = value unless value.nil? @width end |
Instance Method Details
#add_entity(entity, *args) {|entity_instance| ... } ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/game/window.rb', line 60 def add_entity(entity, *args, &blk) entity_name, entity = entity, args.shift if entity.is_a?(Symbol) entity_name ||= entity.to_s.split('::').last.gsub(/[A-Z]/, '_\0').gsub(/^_/, '').downcase (entity_name) { entity } entities << entity_instance = entity.new(@window, *args) yield(entity_instance) if block_given? entity end |
#entities ⇒ Object
56 57 58 |
# File 'lib/game/window.rb', line 56 def entities @entities ||= [] end |
#init_window ⇒ Object
This method is abstract.
Must be overridden by an adapter.
Initialize the underlying adapter window.
76 77 78 |
# File 'lib/game/window.rb', line 76 def init_window raise NotImplementedError end |