Class: Kawaii::TmxTileMap

Inherits:
Object
  • Object
show all
Defined in:
lib/kawaii/tmx_tile_map.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTmxTileMap

Returns a new instance of TmxTileMap.



8
9
10
11
12
# File 'lib/kawaii/tmx_tile_map.rb', line 8

def initialize
	@layers = []
	@properties = {}
	@tilesets = []
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



6
7
8
# File 'lib/kawaii/tmx_tile_map.rb', line 6

def height
  @height
end

#layersObject

Returns the value of attribute layers.



6
7
8
# File 'lib/kawaii/tmx_tile_map.rb', line 6

def layers
  @layers
end

#orientationObject

Returns the value of attribute orientation.



6
7
8
# File 'lib/kawaii/tmx_tile_map.rb', line 6

def orientation
  @orientation
end

#propertiesObject

Returns the value of attribute properties.



6
7
8
# File 'lib/kawaii/tmx_tile_map.rb', line 6

def properties
  @properties
end

#textureObject

Returns the value of attribute texture.



6
7
8
# File 'lib/kawaii/tmx_tile_map.rb', line 6

def texture
  @texture
end

#tile_heightObject

Returns the value of attribute tile_height.



6
7
8
# File 'lib/kawaii/tmx_tile_map.rb', line 6

def tile_height
  @tile_height
end

#tile_widthObject

Returns the value of attribute tile_width.



6
7
8
# File 'lib/kawaii/tmx_tile_map.rb', line 6

def tile_width
  @tile_width
end

#widthObject

Returns the value of attribute width.



6
7
8
# File 'lib/kawaii/tmx_tile_map.rb', line 6

def width
  @width
end

Instance Method Details

#drawObject



14
15
16
17
18
# File 'lib/kawaii/tmx_tile_map.rb', line 14

def draw
	@layers.each do |layer|
		layer.draw
	end
end

#load(path, content_manager) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/kawaii/tmx_tile_map.rb', line 20

def load path, content_manager
	if path.end_with? ".json"
		load_json path
		@layers.each do |layer|
			layer.textures = content_manager.load_tiled_images(@tilesets.first.gsub(/\.\.\//, ""), 32)
		end
	else
		raise UnsupportedFormatError, "only json is supported"
	end
end

#to_sObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/kawaii/tmx_tile_map.rb', line 31

def to_s
	puts "Width: #{@width}"
	puts "Height: #{@height}"
	puts "Orientation: #{@orientation}"
	puts "Tile width: #{@tile_width}"
	puts "Tile height: #{@tile_height}"
	puts ""
	puts "Properties"
	properties.each do |k, v|
		puts "Key: #{k}, Value: #{v}"
	end

	puts ""
	puts "Layers: "
	@layers.each do |l|
		puts l.to_s
	end
end