Simple Tiled Implementation - STI v1.2.3.0

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Uncle_Bones
Prole
Posts: 1
Joined: Wed Aug 12, 2015 11:24 pm

Re: Simple Tiled Implementation - STI v0.12.3.0

Post by Uncle_Bones »

Hey there, I've been using STI for a top-down game of mine for awhile now and just updated today, but I noticed there is an issue with rotated animated tiles not properly rendering. Rotating in Tiled displays the animation fine, but when loaded through STI the animation displays as non-rotated.

For now I can work around the issue, but I figured I'd report the bug in case it hasn't been noticed yet.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Simple Tiled Implementation - STI v0.12.3.0

Post by s-ol »

Is there currently any way of integrating y-Sorted entities into a Tiled map?

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.12.3.0

Post by Karai17 »

Stick 'em in a Custom Layer.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.12.3.0

Post by Karai17 »

Uncle_Bones wrote:Hey there, I've been using STI for a top-down game of mine for awhile now and just updated today, but I noticed there is an issue with rotated animated tiles not properly rendering. Rotating in Tiled displays the animation fine, but when loaded through STI the animation displays as non-rotated.

For now I can work around the issue, but I figured I'd report the bug in case it hasn't been noticed yet.
Sorry for not replying sooner! This is definitely an oversight, I'll see if I can maybe fix it soonish?
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Simple Tiled Implementation - STI v0.12.3.0

Post by s-ol »

Karai17 wrote:Stick 'em in a Custom Layer.
That's what I have been doing, but I don't mean z-ordering, I mean y-ordering.

Image
with a perspective like this, there's all sorts of hackery involved to allow the player to go behind the walls, but also overlap them when in front of them; there are half-high tiles on a layer above the entity layer here.

What I want is that the entities get drawn based on their y-coordinate, whilst the rest of the map is drawn. So instead of drawing the layers bottom-to-top, y=0 to y=max, one at a time, I would like to draw

Code: Select all

for yTileIdx=0,max do
  for i,layer in ipairs(layers) do
     if layer.type == "tiles" then
       layer:drawRow(yTileIdx)
     elseif layer.type == "entities" then
       layer:drawEntitiesBetweenY(yTileIdx*tileHeight, (yTileIdx+1)*tileHeight)
     end
  end
end
in ugly, urealistic pseudocode :D

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
Skeiks
Citizen
Posts: 51
Joined: Wed Jan 28, 2015 1:51 pm

Re: Simple Tiled Implementation - STI v0.12.3.0

Post by Skeiks »

Is there any way or any plan to add the ability to change tile data on the fly?

I'm making a game and I'd like to do destructable ground. For now I'm using objects and going into my collision tile layer and changing a flag for my collision detection. This isn't a problem for the moment because my collision layer is invisible, but it would be cool to be able to remove and add visual tiles.

Ideally, I'd like to be able to call a function, maybe STI:modifyTile(layer,tileX,tileY,newGID), that would edit the sprite batch and the tile instances on the fly.

Thanks for the library though, it's made working on my game much easier
User avatar
JuiceBox
Prole
Posts: 7
Joined: Thu Aug 27, 2015 6:50 am
Location: United States
Contact:

Re: Simple Tiled Implementation - STI v0.12.3.0

Post by JuiceBox »

Man, I found this just at the right time. I just logged onto the forums because I was feeling burnt out over outdated tutorials for Advanced Tiled Loader, and then I found this! Thanks for making this :ultrahappy:
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.12.3.0

Post by Karai17 »

Skeiks wrote:Is there any way or any plan to add the ability to change tile data on the fly?

I'm making a game and I'd like to do destructable ground. For now I'm using objects and going into my collision tile layer and changing a flag for my collision detection. This isn't a problem for the moment because my collision layer is invisible, but it would be cool to be able to remove and add visual tiles.

Ideally, I'd like to be able to call a function, maybe STI:modifyTile(layer,tileX,tileY,newGID), that would edit the sprite batch and the tile instances on the fly.

Thanks for the library though, it's made working on my game much easier

Code: Select all

id = batch:add(tile.quad, tx, ty, tile.r, tile.sx, tile.sy)
self.tileInstances[tile.gid] = self.tileInstances[tile.gid] or {}
table.insert(self.tileInstances[tile.gid], { batch=batch, id=id, gid=tile.gid, x=origx or tx, y=origy or ty })
The above code is in STI and it provides you with some handles. You can manually adjust the sprite batch with the tile instance's batch and id data, and then manually move the table from the current gid instance list to another, but there is no simple api call in STI to do that (yet?). If you'd like to add such a feature, I'd welcome a pull request but as of right now STI isn't a full priority for me, I am more in the maintenance mode than feature mode as I focus on other projects.

I do admit I need to update the documentation to provide more information about these sorts of features...
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.12.3.0

Post by Karai17 »

S0lll0s wrote:
Karai17 wrote:Stick 'em in a Custom Layer.
That's what I have been doing, but I don't mean z-ordering, I mean y-ordering.

Image
with a perspective like this, there's all sorts of hackery involved to allow the player to go behind the walls, but also overlap them when in front of them; there are half-high tiles on a layer above the entity layer here.

What I want is that the entities get drawn based on their y-coordinate, whilst the rest of the map is drawn. So instead of drawing the layers bottom-to-top, y=0 to y=max, one at a time, I would like to draw

Code: Select all

for yTileIdx=0,max do
  for i,layer in ipairs(layers) do
     if layer.type == "tiles" then
       layer:drawRow(yTileIdx)
     elseif layer.type == "entities" then
       layer:drawEntitiesBetweenY(yTileIdx*tileHeight, (yTileIdx+1)*tileHeight)
     end
  end
end
in ugly, urealistic pseudocode :D
https://github.com/excessive/rpg
https://github.com/excessive/rpg/blob/m ... y.lua#L222
https://github.com/excessive/rpg/blob/m ... y.lua#L257

Linked above is a project I worked on a while back, it might provide you with some interesting ideas on how to do what you want to do. Basically, everything is an object and only the unchanging terrain is in a tile layer (or several layers). Each frame does a table.sort to sort the list of objects by its Y axis and then draws them accordingly (within the custom layer's draw function). This gives you massive flexibility when dealing with world objects. You could even use a sprite batch to draw them faster (clear it every frame and re-add the newly sorted objects).
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Simple Tiled Implementation - STI v0.12.3.0

Post by s-ol »

Karai17 wrote: -snip-
https://github.com/excessive/rpg
https://github.com/excessive/rpg/blob/m ... y.lua#L222
https://github.com/excessive/rpg/blob/m ... y.lua#L257

Linked above is a project I worked on a while back, it might provide you with some interesting ideas on how to do what you want to do. Basically, everything is an object and only the unchanging terrain is in a tile layer (or several layers). Each frame does a table.sort to sort the list of objects by its Y axis and then draws them accordingly (within the custom layer's draw function). This gives you massive flexibility when dealing with world objects. You could even use a sprite batch to draw them faster (clear it every frame and re-add the newly sorted objects).
Thats the approach that I am using, but it doesn't fix tile-object sorting. In my tiled map there are tiles that have a z-height (like walls and trees). I want the player to be able to walk and overlap them in front, but to also allow the player to be hidden behind them. The classic approach, and the one I am using right now, is to split these tiles into two pieces, one that is above the object layer, and one that is below it, and to draw the entities inbetween.

This is how curved curse currently works, but it is not a very clean way as it requires a lot of additional tiles and extra attention from the mapper (and errors are not easily spotted).

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Post Reply

Who is online

Users browsing this forum: No registered users and 197 guests