Simple Tiled Implementation - STI v1.2.3.0
Re: Simple Tiled Implementation - STI v0.18.1.0
That would have made the code unreasonably complex for minimal gain, and I needed to render everything to a single batch to fix some rendering issues anyway. I also suspect that the vast majority of people will be making maps 256^2 or smaller, meaning that a single batch would only be 65k tiles. Maps bigger than that are almost always unnecessary and in the case that someone does need to make a huge map, STI supports map offsets so they can just create and load a few individual maps and position them.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.18.1.0
Now that STI has the capability to make randomized maps, I've decided to try working with STI. Alas, integrating it with an existing project turned out to be difficult, so I'm starting from scratch again
Re: Simple Tiled Implementation - STI v0.18.1.0
Karai, I'm having problems accessing the tile data in layer. Specifically, I'm using STI's convertPixeltoTile to know what tile I'm mousing over, then I want to get the gid of that tile to know what kind of a tile it is (wall, floor, etc.). The map is isometric if it matters.
The old method I found in the thread was local tile = self.layers[layer].data[y][x] but I have verified that the self.layers[layer].data doesn't have the [y] or [x] this method expects. I guess this changed at some point. How do I get the gid of the tile if I know it's x and y, then?
The old method I found in the thread was local tile = self.layers[layer].data[y][x] but I have verified that the self.layers[layer].data doesn't have the [y] or [x] this method expects. I guess this changed at some point. How do I get the gid of the tile if I know it's x and y, then?
Re: Simple Tiled Implementation - STI v0.18.1.0
Map.layers[layer].data[y][x] is definitely still there. Make sure to use math.floor on the y and x values you get from the conversion function, as those values are floating point values (so you can use them to convert back to the correct pixel) and not integers.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.18.1.0
Thanks Karai, I managed to figure it out (I was getting the tile under the cursor from love.mouse.getPosition() while I should have used gamera:toWorld().
I'm now wondering how would one implement a FOV with STI, given that STI draws the whole map at once. The part of the map outside FOV would probably have to be masked somehow... maybe I could use the swapTile function to swap the tiles outside FOV for tile 0 (empty)... would that work?
I'm now wondering how would one implement a FOV with STI, given that STI draws the whole map at once. The part of the map outside FOV would probably have to be masked somehow... maybe I could use the swapTile function to swap the tiles outside FOV for tile 0 (empty)... would that work?
Re: Simple Tiled Implementation - STI v0.18.1.0
Just draw a mask on top of the map. or set a scissor before drawing the map.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
-
- Prole
- Posts: 11
- Joined: Sun Feb 12, 2017 4:50 pm
Re: Simple Tiled Implementation - STI v0.18.1.0
First of all, thanks for an awesome library! A couple of questions.
1. What is the recommended way to dynamically change tiles or objects (add/remove) on the map layer?
2. Should I always update/draw my objects without using STI's object layers? I want to use a component approach for my game objects, but still leverage the STI's object layers for the draw order and stuff. The best approach I see right now is to "transform" each object layer on map load by iterating every object from map data, creating game engine's entity for each Tiled's object, adding this new entity to a custom layer and then deleting the source layer (or making it invisible).
3. Is there some kind of optimization when drawing larger maps? I mean if I create very large map, will STI still draw everything that is not visible on screen? (I'm using hump.camera)
1. What is the recommended way to dynamically change tiles or objects (add/remove) on the map layer?
2. Should I always update/draw my objects without using STI's object layers? I want to use a component approach for my game objects, but still leverage the STI's object layers for the draw order and stuff. The best approach I see right now is to "transform" each object layer on map load by iterating every object from map data, creating game engine's entity for each Tiled's object, adding this new entity to a custom layer and then deleting the source layer (or making it invisible).
3. Is there some kind of optimization when drawing larger maps? I mean if I create very large map, will STI still draw everything that is not visible on screen? (I'm using hump.camera)
Re: Simple Tiled Implementation - STI v0.18.1.0
1) https://github.com/karai17/Simple-Tiled ... t.lua#L990
2) That is exactly the correct process.
3) STI is already optimized. It batches every tile into a single draw call (per texture, per layer) so there is no performance overhead for drawing the map.
2) That is exactly the correct process.
3) STI is already optimized. It batches every tile into a single draw call (per texture, per layer) so there is no performance overhead for drawing the map.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
-
- Prole
- Posts: 1
- Joined: Sat Apr 01, 2017 8:32 pm
Re: Simple Tiled Implementation - STI v0.18.1.0
Hi, I'm having a fair amount of trouble getting STI to do much of anything.
First: Tiled outputs my layer data as a single list, e.g.,
but functions like getTileProperties want to access this data like it's a list of lists.
Second, even if I could get this function to work, this isn't where my tile properties are even stored in the first place.
Basically, I'm trying to check if a sprite is on the ground in a platformer-type situation. I want to check if the property "solid" is set for the tiles at my player's feet. I honestly have no idea how to do this using STI's built-in functionality at this point. I appreciate the help. Really, I just wish the documentation provided examples.
First: Tiled outputs my layer data as a single list, e.g.,
Code: Select all
data = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
}
Second, even if I could get this function to work, this isn't where my tile properties are even stored in the first place.
Basically, I'm trying to check if a sprite is on the ground in a platformer-type situation. I want to check if the property "solid" is set for the tiles at my player's feet. I honestly have no idea how to do this using STI's built-in functionality at this point. I appreciate the help. Really, I just wish the documentation provided examples.
Re: Simple Tiled Implementation - STI v0.18.1.0
STI pre-processes the tiled file into its own structure. layer.data changes from a flat table to a table indexed as [y][x]. There is a tutorial linked on the OP of this forum thread I wrote a year or so ago. http://lua.space/gamedev/using-tiled-maps-in-love
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Who is online
Users browsing this forum: No registered users and 2 guests