Simple Tiled Implementation - STI v1.2.3.0

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.14.1.8

Post by Karai17 »

Ah, you mean for draw range. That is something I can work on, yes. You can just disable draw range for now though and it will draw the whole map. This would normally be a bad thing, but since STI uses sprite batches, you aren't making *that* many draw calls. It might be a bit of a snag on mobile, but on a desktop it should run totally fine with drawrange turned off until it is fixed.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
TooMuchAbstraction
Prole
Posts: 7
Joined: Thu Dec 31, 2015 12:58 am

Re: Simple Tiled Implementation - STI v0.14.1.8

Post by TooMuchAbstraction »

Hello, and thanks for adding this functionality to love2d! I'm starting work on a basic platformer based off of this old example. I've made a ton of changes, and one of the things I want to do is switch to STI instead of using Advanced Tiled Loader.

The actual switch went smoothly, but now I need to re-implement one of the modifications that I did with the map as loader by ATL, which is to cull unnecessary edges from the terrain collision detection. Say for example that I have a row of square tiles. If I make a square hitbox for each tile in the row, then I have a bunch of extra edges that the player never ought to be able to run into, but actually can due to the vagaries of how box2d does collision detection. My fix under ATL was to manually generate all of my collision edges using love.physics.newEdgeShape, and adding only those edges that were not adjacent to another solid tile.

It looks, from examination of sti/plugins/box2d.lua, like STI supports specifying custom polygons/polylines for tile collision, which I can probably use as an alternative to manually constructing the hit detection at runtime. In fact it's preferable since I should be able to then create my own sloped tiles and have them Just Work. However, I can't figure out how to access this functionality. I tried setting some custom properties of the tile in Tiled, but they don't appear to have any effect, and I can't find any documentation indicating what I should do. I'm looking specifically at the calculateObjectPosition() method. It seems like it should be able to specify a "shape" property and a "polygon" property, something like this:

Image
(this is looking at the properties of a tile in a tileset)

But this doesn't work. Is there some way to achieve this?

Thanks for your time!

EDIT: some digging shows that it's possible to modify STI to get the polygon "shape" by using "tile.properties.shape or "rectangle"" instead of just "rectangle" whenever it calls calculateObjectPosition. And the custom polygon vertices can be accessed in calculateObjectPosition by adding "or object.properties.polygon" to the "polygon" property of the initialization of the "o" object. However, that property is a string, instead of table of vertex pairs, and I don't know how to convert a string into a list of vertex pairs.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.14.1.8

Post by Karai17 »

Just add the "collidable" property to your object or object layer and set the value to true.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
TooMuchAbstraction
Prole
Posts: 7
Joined: Thu Dec 31, 2015 12:58 am

Re: Simple Tiled Implementation - STI v0.14.1.8

Post by TooMuchAbstraction »

Karai17 wrote:Just add the "collidable" property to your object or object layer and set the value to true.
Yes, I did that, but it just generates a rectangle for every tile. This creates a bunch of unnecessary collision edges between adjacent tiles (which causes collision glitches), and it also means that I can't have sloped tiles.

In any event, check your pull requests. :) Here is an example map that encodes custom collision polygons for some of the tiles, and here are the two tilesets I'm using. The one that doesn't look horribly unprofessional comes from this old tutorial.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.14.1.8

Post by Karai17 »

You can also just create an object layer and manually stick in a few rectangles to cover areas greater than a single tile, or polygons for sloped edges. I looked at your pull request and I personally just don't see the problem that it solves that can't be solved by just using Tiled properly.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
TooMuchAbstraction
Prole
Posts: 7
Joined: Thu Dec 31, 2015 12:58 am

Re: Simple Tiled Implementation - STI v0.14.1.8

Post by TooMuchAbstraction »

For reference, Karai and I sorted this out. Turns out that STI wasn't loading the object group for each tile, which means that any custom collision data added via the Tile Collision Editor wasn't getting loaded and the tiles were defaulting to a rectangular collision hitbox. This is now fixed.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.14.1.10

Post by Karai17 »

I would also like to note that this used to work! It must have broke when I implemented the plugin system ?????
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
TooMuchAbstraction
Prole
Posts: 7
Joined: Thu Dec 31, 2015 12:58 am

Re: Simple Tiled Implementation - STI v0.14.1.10

Post by TooMuchAbstraction »

Since I'm here already, I'd like to be able to place items on the map, which can be picked up by the user. At the moment I have an object layer, and at program start, I'm iterating over all objects in the map and creating bodies and fixtures for them so I can recognize when the player touches them. This works okay, but I can't figure out how to then remove the items from the map. I can remove the bodies I created easily enough, but I can't get the map to stop drawing them.

Is there some other way I should be approaching this? Should I be creating a sprite layer or something?
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Simple Tiled Implementation - STI v0.14.1.10

Post by bobbyjones »

The tutorial on lua.space shows how to remove objects I think.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.14.1.10

Post by Karai17 »

You can remove the objects from map.objects and from the layer to kill them. If you are using a tile object you may need to regenerate the batches
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests