Advanced Tiled Loader - No longer maintained
Re: Advanced Tiled Loader - Updated to 0.12.0!
Thanks, I just put that code in and it works fine, so thanks again.
Keith Weatherby II / twitter / facebook / youtube
IndieFlux - Reviews and more! / Games Afoot Software
IndieFlux - Reviews and more! / Games Afoot Software
Re: Advanced Tiled Loader - Updated to 0.12.1!
This is some code I wrote to convert all the rectangles, polygons, polylines and ellipses in an object layer into static shapes and import them into a love.physics world.
The function can be called like this:
Love's physic engine can then be used to handle collision detection with the terrain or whatever else you decide to mark out.
Code: Select all
function importObjectLayer(world, layer)
for i = 1, #layer.objects do
local obj = layer.objects[i]
local shp = nil
if obj.polyline then
shp = love.physics.newChainShape(false, unpack(obj.polyline))
elseif obj.polygon then
shp = love.physics.newChainShape(true, unpack(obj.polygon))
elseif obj.gid then
--object is a tile, skip
--todo: Consider reading the tile properties to determine if a special shape should be added.
elseif obj.ellipse then
if obj.width == obj.height then
--proper circle
local r = obj.width / 2
shp = love.physics.newCircleShape(r, r, r)
else
--an ellipse
local points = {}
local xr = obj.width / 2
local yr = obj.height / 2
for i=1, 8 do
local ang = math.pi * 2 * i / 8
points[#points + 1] = xr * (1 + math.cos(ang))
points[#points + 1] = yr * (1 + math.sin(ang))
end
shp = love.physics.newChainShape(true, unpack(points))
end
else
--rectangles
--Don't use love.physics.newRectangleShape(), as it will create a rectangle centered around 0, 0.
shp = love.physics.newPolygonShape(0, 0, obj.width, 0, obj.width, obj.height, 0, obj.height)
end
if shp ~= nil then
local bdy = love.physics.newBody(world, obj.x, obj.y, "static")
local fxt = love.physics.newFixture(bdy, shp)
end
end
end
Code: Select all
love.physics.setMeter(32)
world = love.physics.newWorld(0, 0, true)
map = loader.load("somemap.tmx")
importObjectLayer(world, map("Obstructions"))
Re: Advanced Tiled Loader - Updated to 0.12.1!
Tiled 0.9.0 was released yesterday so between getting support for that and refactoring the loading and rendering code I'm going to be busy. I just wanted to let everyone know I'm hard at work on the next version.
Also thanks for the code xenodora. I'm still reviewing your commit on github.
Also thanks for the code xenodora. I'm still reviewing your commit on github.
Re: Advanced Tiled Loader - Updated to 0.12.1!
Thanks for all the hard work Kadoba!
Keith Weatherby II / twitter / facebook / youtube
IndieFlux - Reviews and more! / Games Afoot Software
IndieFlux - Reviews and more! / Games Afoot Software
Re: Advanced Tiled Loader - Updated to 0.12.1!
How does one currently access an object in an object layer?
Keith Weatherby II / twitter / facebook / youtube
IndieFlux - Reviews and more! / Games Afoot Software
IndieFlux - Reviews and more! / Games Afoot Software
Re: Advanced Tiled Loader - Updated to 0.12.1!
Code: Select all
map("ObjectLayer").objects[number]
Re: Advanced Tiled Loader - Updated to 0.12.1!
Just a status update.
I've been working on the next version of ATL for a while now and I've decided to take it in a new direction. I want to put more of an emphasis as ATL as a loader and less on rendering. I've realized that ATL just tries to do too many things outside of its design scope and it really affects the complexity and maintainability of the library. That means I'm going to cut out a lot of fat. In some cases this will mean more work for the user. However I'm convinced that by narrowing the focus this will ultimately make ATL easier to understand, more flexible, and a better library overall.
The new loading system will make it possible to convert formats between tmx files, lua files, simple tables, and ATL maps. This means you can do things like turn exported lua map files back into the native tmx format or use ATL just for loading/saving map data and come up with your own rendering scheme.
Additionally, I am seriously considering dropping rendering support for isometric maps. From what I have experienced it is a rarely used feature and it has a high cost in terms of maintainability and code complexity. It will be possible to load/save between isometric files and simple tables, you just wont be able to turn them into renderable ATL maps.
It will likely be late next week before I finish the new version. Here's what the current patch notes for 0.13.0 looks like:
I've been working on the next version of ATL for a while now and I've decided to take it in a new direction. I want to put more of an emphasis as ATL as a loader and less on rendering. I've realized that ATL just tries to do too many things outside of its design scope and it really affects the complexity and maintainability of the library. That means I'm going to cut out a lot of fat. In some cases this will mean more work for the user. However I'm convinced that by narrowing the focus this will ultimately make ATL easier to understand, more flexible, and a better library overall.
The new loading system will make it possible to convert formats between tmx files, lua files, simple tables, and ATL maps. This means you can do things like turn exported lua map files back into the native tmx format or use ATL just for loading/saving map data and come up with your own rendering scheme.
Additionally, I am seriously considering dropping rendering support for isometric maps. From what I have experienced it is a rarely used feature and it has a high cost in terms of maintainability and code complexity. It will be possible to load/save between isometric files and simple tables, you just wont be able to turn them into renderable ATL maps.
It will likely be late next week before I finish the new version. Here's what the current patch notes for 0.13.0 looks like:
- Removed rendering support for isometric maps
- Loader.path and Loader.saveDirectory have been removed
- Added Convert.lua to handle conversions between tmx, lua, tables, and ATL maps.
- Added support for Tiled 0.9.0 features
- Revamped rendering algorithm. Improved speeds significantly under certain conditions.
- Revamped loading algorithm. Improved loading speeds and supports more formats.
- Maps no longer keep track of the draw range. The values for it must be passed manually when calling draw functions.
- Improved interface for flipped and rotated tiles.
-
- Prole
- Posts: 2
- Joined: Fri Mar 22, 2013 5:24 am
Re: Advanced Tiled Loader - Updated to 0.12.1!
I've been trying to learn to use ATL recently, and I have a situation where I need to know the first GID of one of the two tilesets attached to the map I'm loading. This seemed like it would be fairly straight forward. The map documentation says that tileset information is held in map.tilesets. When I try to access it, though, I get "Error: main.lua:26: attempt to call field 'tilesets' (a table value)"
I couldn't find anything in the documentation that would tell me how to get that information other that this, so anyone know how to actually do it?
I couldn't find anything in the documentation that would tell me how to get that information other that this, so anyone know how to actually do it?
Re: Advanced Tiled Loader - Updated to 0.12.1!
It sounds like you're trying to call the tilesets table like a function.
Code: Select all
-- you might be doing this:
map.tilesets("tilesetname").firstgid
-- when you need to be doing this:
map.tilesets["tilesetname"].firstgid
-
- Prole
- Posts: 2
- Joined: Fri Mar 22, 2013 5:24 am
Re: Advanced Tiled Loader - Updated to 0.12.1!
Thank you. I'm still new to LUA, and it's little language details like that that seem to get me at the moment.
Who is online
Users browsing this forum: No registered users and 1 guest