Class: Nimo::GameBuilder
Instance Method Summary collapse
-
#fonts(font_definitions) ⇒ Object
Load fonts that can be referenced by a tag.
-
#images(image_definitions) ⇒ Object
Load images that can be referenced by a tag.
-
#initialize(game_window) ⇒ GameBuilder
constructor
A new instance of GameBuilder.
-
#screen(screen_id, &blk) ⇒ Object
Register a new screen with the
name
, using the supplied block as the Screen constructor. -
#sounds(sound_definitions) ⇒ Object
Load sounds that can be referenced by a tag.
Constructor Details
#initialize(game_window) ⇒ GameBuilder
Returns a new instance of GameBuilder.
24 25 26 27 |
# File 'lib/nimo/utils/game.rb', line 24 def initialize(game_window) @game_window = game_window @resources = Nimo::Resources.new(@game_window) end |
Instance Method Details
#fonts(font_definitions) ⇒ Object
Load fonts that can be referenced by a tag. Example of font_definitions
:
fonts :some_tag => { :type => "font_type", :size => 20 } # Load font of type 'font_type'
42 43 44 |
# File 'lib/nimo/utils/game.rb', line 42 def fonts(font_definitions) @resources.load_fonts(font_definitions) end |
#images(image_definitions) ⇒ Object
Load images that can be referenced by a tag. Example of image_definitions
:
images :some_tag => { :filename => "path_to_image.png" } # Load path_to_image.png to be used by the tag :some_tag
images :tile_tag => { :filename => "path_to_tile.png", :tile_dimension => [32, 50] } # Load path_to_tile.png as a tile of width 32 and height 50
34 35 36 |
# File 'lib/nimo/utils/game.rb', line 34 def images(image_definitions) @resources.load_images(image_definitions) end |
#screen(screen_id, &blk) ⇒ Object
Register a new screen with the name
, using the supplied block as the Screen constructor.
56 57 58 59 60 |
# File 'lib/nimo/utils/game.rb', line 56 def screen(screen_id, &blk) screen = Nimo::Screen.new(screen_id, @game_window, @resources) screen.instance_eval(&blk) if block_given? @game_window.add_screen(screen_id, screen) end |
#sounds(sound_definitions) ⇒ Object
Load sounds that can be referenced by a tag. Example of sound_definitions
:
sounds :some_tag => { :filename => "some_file.wav", :size => 20 }
50 51 52 |
# File 'lib/nimo/utils/game.rb', line 50 def sounds(sound_definitions) @resources.load_sounds(sound_definitions) end |