Class: Gosu::Tiled::Map

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(window, data, data_dir) ⇒ Map

Returns a new instance of Map.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gosu_tiled/map.rb', line 6

def initialize(window, data, data_dir)
  @window = window
  @data = data
  @data_dir = data_dir
  @width = data['width'] * data['tilewidth']
  @height = data['height'] * data['tileheight']
  @tilesets = Tilesets.new(window, data['tilesets'], data_dir)
  @layers = Layers.new(window,
                       data['layers'],
                       width: @width,
                       height: @height,
                       tile_width: data['tilewidth'],
                       tile_height: data['tileheight'])
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



4
5
6
# File 'lib/gosu_tiled/map.rb', line 4

def height
  @height
end

#layersObject (readonly)

Returns the value of attribute layers.



4
5
6
# File 'lib/gosu_tiled/map.rb', line 4

def layers
  @layers
end

#tilesetsObject (readonly)

Returns the value of attribute tilesets.



4
5
6
# File 'lib/gosu_tiled/map.rb', line 4

def tilesets
  @tilesets
end

#widthObject (readonly)

Returns the value of attribute width.



4
5
6
# File 'lib/gosu_tiled/map.rb', line 4

def width
  @width
end

Instance Method Details

#draw(offset_x, offset_y) ⇒ Object



21
22
23
24
25
# File 'lib/gosu_tiled/map.rb', line 21

def draw(offset_x, offset_y)
  @layers.each do |layer|
    layer.draw(offset_x, offset_y, tilesets)
  end
end