Simple Tiled Implementation - STI v1.2.3.0
Re: Simple Tiled Implementation - STI v0.16.0.3
Added a PayPal link to the OP and the README. No pressure!
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é
- aloisdeniel
- Prole
- Posts: 17
- Joined: Sat Jan 30, 2016 5:57 pm
- Contact:
Re: Simple Tiled Implementation - STI v0.16.0.3
Great lib Karai, saved me hours of work!
I have still two questions for my current project :
- Is it possible to give a map an already loaded tileset image ? I'm currently developing a level selection with a small preview and all my maps have the same tileset ... I don't want to load the same image for each one of them.
- Is there a way to merge all boxes from consecutive tiles ? For example, a set of similar tiles could be merged into
Thanks.
I have still two questions for my current project :
- Is it possible to give a map an already loaded tileset image ? I'm currently developing a level selection with a small preview and all my maps have the same tileset ... I don't want to load the same image for each one of them.
- Is there a way to merge all boxes from consecutive tiles ? For example, a set of similar tiles
Code: Select all
{{x=1,y=0,w=1,h=1}, {x=2,y=0,w=1,h=1}}
Code: Select all
{{x=1,y=0,w=2,h=1}}
My LÖVE libraries : pixelatlas, pixelmap
Re: Simple Tiled Implementation - STI v0.16.0.3
sti caches textures so if you use the same sti object, it should be fine. (sti.flush clears the cache)
as for the collision merging, i have not implemented that. you would need to write your own collision plugin (or modify one of the current ones)
as for the collision merging, i have not implemented that. you would need to write your own collision plugin (or modify one of the current ones)
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é
- aloisdeniel
- Prole
- Posts: 17
- Joined: Sat Jan 30, 2016 5:57 pm
- Contact:
Re: Simple Tiled Implementation - STI v0.16.0.3
Okay great!
I'll post my (modified box2d) plugin here as soon I'll do it, I was already doing it for one of my libs so it shouldn't be too hard to adapt it.
Thanks!
I'll post my (modified box2d) plugin here as soon I'll do it, I was already doing it for one of my libs so it shouldn't be too hard to adapt it.
Thanks!
My LÖVE libraries : pixelatlas, pixelmap
Re: Simple Tiled Implementation - STI v0.16.0.3
Hey folks, new user here. I got a problem that I've been beating my head in all day over, so I figure it's time to ask for help.
I'm new to Lua and Love2d but not necessarily game development or programming in general (but I am pretty rusty).
What I'm trying to do is create a simple racing game. A motocross dude is driven along a track (strictly left to right).
I built the track in Tiled and imported it to my program using STI. Following the tutorials/examples, I got scrolling and collision all working fine.
But I can't for the life of me figure out how to loop a track! Like say, multiple laps.
I feel like this is something simple and I'm just not able to wrap my head around Lua and/or Love2d. I've built similar games in Java and C++ and this was a relatively easy problem to solve.
Through canvases I have got a flat image of the track to loop - but no collision, objects, or layer data. The tile-based scrolling tutorials I've read don't seem to apply with STI's love.graphics.translate() and map:draw() strategy.
Making multiple instances of my track and offsetting them kinda works but it seems pretty wasteful if I want to do 10+ laps...doesn't it?
Any ideas would be greatly appreciated!
I'm new to Lua and Love2d but not necessarily game development or programming in general (but I am pretty rusty).
What I'm trying to do is create a simple racing game. A motocross dude is driven along a track (strictly left to right).
I built the track in Tiled and imported it to my program using STI. Following the tutorials/examples, I got scrolling and collision all working fine.
But I can't for the life of me figure out how to loop a track! Like say, multiple laps.
I feel like this is something simple and I'm just not able to wrap my head around Lua and/or Love2d. I've built similar games in Java and C++ and this was a relatively easy problem to solve.
Through canvases I have got a flat image of the track to loop - but no collision, objects, or layer data. The tile-based scrolling tutorials I've read don't seem to apply with STI's love.graphics.translate() and map:draw() strategy.
Making multiple instances of my track and offsetting them kinda works but it seems pretty wasteful if I want to do 10+ laps...doesn't it?
Any ideas would be greatly appreciated!
Re: Simple Tiled Implementation - STI v0.16.0.3
rot,
I've never done a game like this, so others probably have better ideas, but one idea that comes to mind is to dynamically modify the map, moving a tiles from the beginning of the map to the end of the map, one column at a time, based on how close the player is to reaching the end of the map. But IIRC the Tiled format and the STI library wouldn't make this easy (I think the 2D array of tiles is mapped onto a 1D array and the width and height and x/y positions of the map are in separate properties that would need to be updated each time, etc).
> Making multiple instances of my track and offsetting them kinda works but it seems pretty wasteful if I want to do 10+ laps...doesn't it?
Actually, I think it's mostly just the graphics that are resource intensive. The other data, at least in the Tiled lua format, is pretty lightweight. It may not be that wasteful to make 10+ instances of the track, provided they reference the same tileset image. *EDIT: Above someone mentions that STI caches tileset images, so it maybe that making 10+ instances will work fine & won't load 10 copies of the image, as I assumed it would.* IOW, instead of re-loading the TileMap 10x, you might be able to take a single TileMap and dynamically replicate the tile data array inside the TileMap 10x. That may not be super-easy, but it'd be easier than dynamically shifting tiles around while the game is running, as proposed in the above paragraph.
FWIW, this strikes me as a similar problem to the one solved by infinite scrolling/running games; there may be well-known solutions (maybe even libraries or open-source game code) to this problem.
I've never done a game like this, so others probably have better ideas, but one idea that comes to mind is to dynamically modify the map, moving a tiles from the beginning of the map to the end of the map, one column at a time, based on how close the player is to reaching the end of the map. But IIRC the Tiled format and the STI library wouldn't make this easy (I think the 2D array of tiles is mapped onto a 1D array and the width and height and x/y positions of the map are in separate properties that would need to be updated each time, etc).
> Making multiple instances of my track and offsetting them kinda works but it seems pretty wasteful if I want to do 10+ laps...doesn't it?
Actually, I think it's mostly just the graphics that are resource intensive. The other data, at least in the Tiled lua format, is pretty lightweight. It may not be that wasteful to make 10+ instances of the track, provided they reference the same tileset image. *EDIT: Above someone mentions that STI caches tileset images, so it maybe that making 10+ instances will work fine & won't load 10 copies of the image, as I assumed it would.* IOW, instead of re-loading the TileMap 10x, you might be able to take a single TileMap and dynamically replicate the tile data array inside the TileMap 10x. That may not be super-easy, but it'd be easier than dynamically shifting tiles around while the game is running, as proposed in the above paragraph.
FWIW, this strikes me as a similar problem to the one solved by infinite scrolling/running games; there may be well-known solutions (maybe even libraries or open-source game code) to this problem.
Re: Simple Tiled Implementation - STI v0.16.0.3
I believe you're right - STI does cache the image data. I'm not too concerned with the resource use but management of the 10+ collision maps, objects, moving the player's sprite to the next map...it does sort of work (see below) but I couldn't help but feel that there should be a better way.peterrust wrote:rot,
Actually, I think it's mostly just the graphics that are resource intensive. The other data, at least in the Tiled lua format, is pretty lightweight. It may not be that wasteful to make 10+ instances of the track, provided they reference the same tileset image. *EDIT: Above someone mentions that STI caches tileset images, so it maybe that making 10+ instances will work fine & won't load 10 copies of the image, as I assumed it would.* IOW, instead of re-loading the TileMap 10x, you might be able to take a single TileMap and dynamically replicate the tile data array inside the TileMap 10x. That may not be super-easy, but it'd be easier than dynamically shifting tiles around while the game is running, as proposed in the above paragraph.
What I've done, in pseudo-code:
Inside love.load()
Code: Select all
lap1 = sti("track", {box2d})
lap2 = sti("track", {box2d}, offsetx, 0)
lap3 = sti("track", {box2d, offsetx*2, 0)
world = love.physics.newWorld(0,0)
lap1:box2d_init(world)
lap2:box2d_init(world)
lap3:box2d_init(world)
Code: Select all
world:update(dt)
-- player input and movement processed, player sprite given a x and y value
lap1:update(dt)
lap2:update(dt)
lap3:update(dt)
Code: Select all
love.graphics.translate(as per STI example)
lap1:draw()
lap2:draw()
lap3:draw()
But I have a new problem: collision data on any map after the 1st gets offset by one track map width??
Same here, which is why I'm feeling that there's something basic I'm missing.peterrust wrote: FWIW, this strikes me as a similar problem to the one solved by infinite scrolling/running games; there may be well-known solutions (maybe even libraries or open-source game code) to this problem.
EDIT: I fixed my collision offset problem. The offset was being applied to the specific map but I'm trying to apply map offsets globally. I can fix this by changing in box2d plugin
Code: Select all
local body = love.physics.newBody(world, map.offsetx, map.offsety)
Code: Select all
local body = love.physics.newBody(world)
Re: Simple Tiled Implementation - STI v0.3.1
I have no idea how I'm going to handle objects, sprites, custom layers, etc. I'm kinda winging it and making it up as I go along.pauljessup wrote:How do you plan on handling objects? I am curious about this. When I was working on my own Tiled loader, I was just referencing them and then creating in game objects based on an ID I assigned to them. Wasn't a lot of fun to work with that way (eg: cheap hack!). I'm working on the Tiled importer for Greentea, and was just wondering on what you plan on doing/how it will compare/etc to other libs way of doing it (Lovely Tiles, etc).
Right now I'm trying to juggle passing the player sprite over from one lap's map to the next one without any hiccup in the gameplay. Current status as I type this: player sprite gets passed over to new map and the collision data is there and plays fine but the actual sprite is rendered under the tilemap.
I can't imagine all the work I'll have to do with other sprites, objects, etc, etc.
Re: Simple Tiled Implementation - STI v0.16.0.3
Hey
"sorry for the broken english"
I'm really new to Love2d and for the past days I've experimented quite a lot reading the wiki and the docs of somes libraries including STI (really great tool btw)
I can set up everything right, the tile map is drawn, my player on a custom layer is also drawn, but the only issue I have is the collision part...
I can't make it work, I'm using the same code as your tutorial on Lua.Space and tried to implement your code from the tech demo for the collision part, nothing happens
My tile map has objects with collidable set to true in Tiled
I'm sure it's really simple to fix
Thanks in advance
"sorry for the broken english"
I'm really new to Love2d and for the past days I've experimented quite a lot reading the wiki and the docs of somes libraries including STI (really great tool btw)
I can set up everything right, the tile map is drawn, my player on a custom layer is also drawn, but the only issue I have is the collision part...
I can't make it work, I'm using the same code as your tutorial on Lua.Space and tried to implement your code from the tech demo for the collision part, nothing happens
My tile map has objects with collidable set to true in Tiled
I'm sure it's really simple to fix
Thanks in advance
Re: Simple Tiled Implementation - STI v0.16.0.3
Just mentioning this because it caught me out following the tutorial:Ovanity wrote:
My tile map has objects with collidable set to true in Tiled
I'm sure it's really simple to fix
Thanks in advance
Is collidable a string that says, "true", like in the tutorial, or is it a bool that equals true?
Because it has to be a bool, STI was updated since that tutorial was written.
Who is online
Users browsing this forum: No registered users and 4 guests