Advanced Tiled Loader - No longer maintained

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: Advanced Tiled Loader

Post by Kadoba »

KingRecycle wrote: Well it checks if the next tile has the obstacle property. Takes the tile the player is on and adds to it the direction the player is moving for the next tile.

So if the next tile is an obstacle tile it doesn't let the player move that direction.

All right. It looks like you are testing if the collision is happening on the current location of the player rather than where the player will be at. So that would let the player move onto an obstacle but never off of it.
User avatar
KingRecycle
Prole
Posts: 44
Joined: Thu May 24, 2012 1:01 am

Re: Advanced Tiled Loader

Post by KingRecycle »

Kadoba wrote:
KingRecycle wrote: Well it checks if the next tile has the obstacle property. Takes the tile the player is on and adds to it the direction the player is moving for the next tile.

So if the next tile is an obstacle tile it doesn't let the player move that direction.

All right. It looks like you are testing if the collision is happening on the current location of the player rather than where the player will be at. So that would let the player move onto an obstacle but never off of it.
I've already changed so much of the code since I last posted.

I been trying to get movement like you see in the Pokemon games but to no avail.
I was doing so many things that I destroyed the current code and probably going to start from the example again.
If you have any idea how I can get movement as I said above and also do obstacle checking then I will appreciate it a lot as I been trying to do this since last thursday. :(
User avatar
litearc
Citizen
Posts: 57
Joined: Thu May 17, 2012 12:40 am

Re: Advanced Tiled Loader

Post by litearc »

Sorry if this has been asked already, but does Tiled come with a built in tile animation feature or auto-tiling features? I guess animations could be done by setting tile properties, but it seems like it would be a common thing. If these features exist, does your loader support them?
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: Advanced Tiled Loader

Post by Kadoba »

KingRecycle wrote: I've already changed so much of the code since I last posted.

I been trying to get movement like you see in the Pokemon games but to no avail.
I was doing so many things that I destroyed the current code and probably going to start from the example again.
If you have any idea how I can get movement as I said above and also do obstacle checking then I will appreciate it a lot as I been trying to do this since last thursday. :(
You might want to tackle the movement code separately and come back once you have a good feel for it. Try and do the Gridlocked Player tutorial and post in the support and development forum if you have trouble. Your question will get a lot more exposure and get answered faster there. Also the ATL examples are really bad to build off of. They are meant to just get things moving around and show how to do basic operations. I suppose I need to get around to doing proper tutorials.

litearc wrote:Sorry if this has been asked already, but does Tiled come with a built in tile animation feature or auto-tiling features? I guess animations could be done by setting tile properties, but it seems like it would be a common thing. If these features exist, does your loader support them?
Tiled does have an automapping feature but no animations. I believe that the output for automaps are the same as regular maps so ATL should be able to handle them.
User avatar
scgrn
Prole
Posts: 1
Joined: Sat Jun 09, 2012 8:07 am

Re: Advanced Tiled Loader

Post by scgrn »

Hi everyone! This is my first post in the Love2d forums.

I've started playing around with ATL and it's pretty great, but I've run into a small problem.
I'm trying to write to my tilemap so I can have animated tiles in-game.

I have a simple *.tmx with one layer and one tileset. Here's my code for loading the map and attempting to alter a tile:

Code: Select all

local loader = require("src.AdvTiledLoader.Loader")
loader.path = "maps/"
loader.filterMin = "linear"
loader.filterMax = "linear"
loader.useSpriteBatch = true
loader.drawObjects = false

function loadMap(index, startX, startY)
	map = loader.load(string.format("map%02d.tmx", index))
	
	-- camera setup removed
	
	print(map.tileLayers["Tile Layer 1"].tileData:get(5, 5).id)
	
	local tile = map.tileLayers["Tile Layer 1"].tileData(5,5)
	tile.id = 2
	map.tileLayers["Tile Layer 1"].tileData:set(5, 5, tile)
	map:updateTiles()
	
	print(map.tileLayers["Tile Layer 1"].tileData:get(5, 5).id)
end
The print statements show that the tile ID is being changed, but at runtime my tilemap looks unchanged. What am I missing?

Thanks for any help!
JumperKenny
Prole
Posts: 3
Joined: Tue Aug 28, 2012 6:21 pm

Re: Advanced Tiled Loader

Post by JumperKenny »

Hi!
I'm a beginner on löve and would like to ask if it's possible to find out where a specific tile is drawn..

If I have a grass map and there is one stone in the grass
How can i get the x,y of the stone

I'm sorry for my bad english :( :P
User avatar
KingRecycle
Prole
Posts: 44
Joined: Thu May 24, 2012 1:01 am

Re: Advanced Tiled Loader

Post by KingRecycle »

It's probably posted somewhere but I didn't see it but is there a way to hide objects (not remove)?
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: Advanced Tiled Loader

Post by Kadoba »

JumperKenny wrote:Hi!
I'm a beginner on löve and would like to ask if it's possible to find out where a specific tile is drawn..

If I have a grass map and there is one stone in the grass
How can i get the x,y of the stone

I'm sorry for my bad english :( :P
You have to iterate through all of the tiles when you load the map and mark the ones you want.

Here's a quick example:

Code: Select all

local stone = {}
local layer = map.tileLayers["ground"]

for x, y, tile in layer.tileData:iterate() do
   if tile.properties.type == "stone" then
      stone[ #stone+1 ] = tile
   end
end
KingRecycle wrote:It's probably posted somewhere but I didn't see it but is there a way to hide objects (not remove)?
You can hide all objects by setting map.drawObjects to false. You can't hide individual objects.
JumperKenny
Prole
Posts: 3
Joined: Tue Aug 28, 2012 6:21 pm

Re: Advanced Tiled Loader

Post by JumperKenny »

Kadoba wrote:
You have to iterate through all of the tiles when you load the map and mark the ones you want.

Here's a quick example:

Code: Select all

local stone = {}
local layer = map.tileLayers["ground"]

for x, y, tile in layer.tileData:iterate() do
   if tile.properties.type == "stone" then
      stone[ #stone+1 ] = tile
   end
end
And now if I want to print the x and y i have to...?

Code: Select all

love.graphics.print("X: " .. stone[#stone].x .. " Y: " .. stone[#stone].y,0,0)
Does not work.

I'm feeling dumb :(
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: Advanced Tiled Loader

Post by Kadoba »

JumperKenny wrote: And now if I want to print the x and y i have to...?

Code: Select all

love.graphics.print("X: " .. stone[#stone].x .. " Y: " .. stone[#stone].y,0,0)
Does not work.

I'm feeling dumb :(
Oh that's my fault. You actually probably just want to store the x and y values. There's actually just one Tile object for each tile type.

Code: Select all

local stone = {}
local layer = map.tileLayers["ground"]

for x, y, tile in layer.tileData:iterate() do
   if tile.properties.type == "stone" then
      stone.tile = tile  -- Store the stone tile object
      stone[ #stone+1 ] = {x=x, y=y} -- Store the location
   end
end
After you run that code then the stone table will hold the information about the tile.

stone.tile will be the Tile object itself
stone[1] will be the first stone tile location
stone[2] will be the second stone tile location
etc...

So to print the first (or only) tile then you would do this:

Code: Select all

love.graphics.print( stone[1].x, stone[1].y, 0, 0 )
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests