Class: Bestguigui::Tiled::Map

Inherits:
Object
  • Object
show all
Defined in:
lib/bestguigui/tiled.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Map

Returns a new instance of Map.



23
24
25
26
27
28
29
30
# File 'lib/bestguigui/tiled.rb', line 23

def initialize(path)
  data = JSON.parse(File.read(path))
  @width = data["width"]
  @height = data["height"]
  @tile_width = data["tilewidth"]
  @tile_height = data["tileheight"]
  @layers = data["layers"].map { |layer_data| build_layer(layer_data) }
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



21
22
23
# File 'lib/bestguigui/tiled.rb', line 21

def height
  @height
end

#layersObject (readonly)

Returns the value of attribute layers.



21
22
23
# File 'lib/bestguigui/tiled.rb', line 21

def layers
  @layers
end

#tile_heightObject (readonly)

Returns the value of attribute tile_height.



21
22
23
# File 'lib/bestguigui/tiled.rb', line 21

def tile_height
  @tile_height
end

#tile_widthObject (readonly)

Returns the value of attribute tile_width.



21
22
23
# File 'lib/bestguigui/tiled.rb', line 21

def tile_width
  @tile_width
end

#widthObject (readonly)

Returns the value of attribute width.



21
22
23
# File 'lib/bestguigui/tiled.rb', line 21

def width
  @width
end

Instance Method Details

#object_layer(name = nil) ⇒ Object

Première couche d'objets (ou celle nommée name), ou nil s'il n'y en a pas.



40
41
42
# File 'lib/bestguigui/tiled.rb', line 40

def object_layer(name = nil)
  find_layer(ObjectLayer, name)
end

#tile_layer(name = nil) ⇒ Object

Première couche de tuiles (ou celle nommée name), ou nil s'il n'y en a pas.



34
35
36
# File 'lib/bestguigui/tiled.rb', line 34

def tile_layer(name = nil)
  find_layer(TileLayer, name)
end