Class: Gosu::Tiled::Layer

Inherits:
Object
  • Object
show all
Defined in:
lib/gosu_tiled/layer.rb

Instance Method Summary collapse

Constructor Details

#initialize(window, data, options) ⇒ Layer

Returns a new instance of Layer.



4
5
6
7
8
# File 'lib/gosu_tiled/layer.rb', line 4

def initialize(window, data, options)
  @window = window
  @data = data
  @options = options
end

Instance Method Details

#draw(x, y, tilesets) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/gosu_tiled/layer.rb', line 18

def draw(x, y, tilesets)
  if type == 'tilelayer'
    draw_tiles(x, y, tilesets)
  elsif type == 'objectgroup'
    draw_objects(x, y, tilesets)
  end
end

#screen_height_in_tilesObject



30
31
32
# File 'lib/gosu_tiled/layer.rb', line 30

def screen_height_in_tiles
  (@window.height / tile_height.to_f).ceil
end

#screen_width_in_tilesObject



26
27
28
# File 'lib/gosu_tiled/layer.rb', line 26

def screen_width_in_tiles
  (@window.width / tile_width.to_f).ceil
end

#typeObject



14
15
16
# File 'lib/gosu_tiled/layer.rb', line 14

def type
  @data['type']
end

#visible?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/gosu_tiled/layer.rb', line 10

def visible?
  @data['visible']
end