TileMap parser can now load spawn locations, added construction yard building, added particle emitters, added smoke sprite and svg.

This commit is contained in:
2019-11-20 12:51:24 -06:00
parent 7775ccb3a3
commit a9307733e3
10 changed files with 476 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
class IMICRTS
class TiledMap
attr_reader :width, :height, :tile_size
attr_reader :layers, :tilesets
attr_reader :layers, :tilesets, :spawnpoints
def initialize(map_file)
@xml = Nokogiri::XML(File.read("#{IMICRTS::ASSETS_PATH}/#{map_file}"))
@@ -10,6 +10,7 @@ class IMICRTS
@layers = []
@tilesets = []
@spawnpoints = []
@tiles = []
@@ -33,6 +34,15 @@ class IMICRTS
@xml.search("//layer").each do |layer|
@layers << Layer.new(layer)
end
@xml.search("//objectgroup").each do |objectgroup|
if objectgroup.attr("name") == "spawns"
objectgroup.children.each do |object|
next unless object.attr("name") && object.attr("name").downcase.strip == "spawn"
@spawnpoints << SpawnPoint.new(object)
end
end
end
end
def get_tile(tile_id)
@@ -121,5 +131,14 @@ class IMICRTS
end
end
end
class SpawnPoint
attr_reader :x, :y
def initialize(xml_object)
@x, @y = Integer(xml_object.attr("x")), Integer(xml_object.attr("y"))
end
end
end
end