Simple Tiled Implementation - STI v1.2.3.0

Showcase your libraries, tools and other projects that help your fellow love users.
Clean3d
Prole
Posts: 30
Joined: Fri Mar 29, 2013 4:16 pm

Re: Simple Tiled Implementation - STI v0.6.14

Post by Clean3d »

Unfortunately, if you want a good solution I can't help you. I have seperate .png images for each frame in the animation. All I'm doing is swapping out the image in the tileset and regenerating sprite batches. :oops: My animations are only about 1fps, so I just hold my nose and put up with the clunkiness of this method.

Isn't there a Tiled branch with animated tiles? I'm hoping they'll still put that in 0.9.2 and then I can use it instead of my hack. It works for now, though.
Clean3d's Twitter, Game, and Blog
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.6.16

Post by Karai17 »

Yeah, Tiled 0.9.2 will have animations. You can actually download a nightly with animation support. Regenerating sprite batches seems like the only real way to go about it.

Edit: The spacing bug has now been fixed!
Edit: Also made ellipses less stupid~
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
Cerulean Knight
Prole
Posts: 5
Joined: Mon Aug 12, 2013 1:48 pm

Re: Simple Tiled Implementation - STI v0.6.16

Post by Cerulean Knight »

Congrats for this library, STI is very good, simple, and has a great potential!

I'm using this, and was very easy to do everything work.

I want to do a suggestion, it would be great that we can access to the properties of the objects in the map, not only to draw a polygon, but for set startpoints or events, taking the (for example) the coordinates of an object (or even a propertie that we can set in the object itself).

Maybe you can suggest me a better way to do this, I'm starting so, I have a lot to learn.

Excuse me if something is confusing, I'm no native english speaker :P
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.6.16

Post by Karai17 »

Thanks for choosing STI! To access Tile properties, you can do the following:

Code: Select all

local STI = require "sti"
local map = sti.new("map")

local prop = map.tiles[1234].properties -- select the properties from Tile 1234
Using Map.tiles[TILE].properties, you can access all of the properties from any tile in any tileset.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
ochetski
Prole
Posts: 3
Joined: Thu Mar 20, 2014 9:46 pm

Re: Simple Tiled Implementation - STI v0.6.16

Post by ochetski »

Great lib, Karai17!
I've been testing it for a while now with "Tiled" generated maps, and it seems great.
Very few problems, but maybe it's just my low knowledge of your lib.

I have a few questions and hope it can help more people:

- Is there a way to get tile size from collision map? Did not found anything on your documentation.

- Have anyone used STI with a collision lib like love.physics or HardonCollider?

Links, cuz everyone löves them:
https://www.love2d.org/wiki/Tutorial:Ph ... nCallbacks
https://love2d.org/wiki/HardonCollider
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.6.16

Post by Karai17 »

1) The built-in collision map has no actual size, it is just a binary map so it inherits the same size as the map tiles

2) I am unaware of anyone using STI coupled with external collision libs, but I would love to know of any results!
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
ochetski
Prole
Posts: 3
Joined: Thu Mar 20, 2014 9:46 pm

Re: Simple Tiled Implementation - STI v0.6.16

Post by ochetski »

I asked because I did implemented a collision system with STI. But needed to set the tile sizes hard coded, because I wasn't able to get tiles width and height from the map.

My collision system is now ugly, complex and hard to use with multiple entities. I will probably change it to use love.physics. I will share it here as soon as I finish it.

Thanks Karai, please keep the good work because it will bring great games to life.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.6.16

Post by Karai17 »

You should be able to access map.tilewidth and map.tileheight without any problem.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
Cerulean Knight
Prole
Posts: 5
Joined: Mon Aug 12, 2013 1:48 pm

Re: Simple Tiled Implementation - STI v0.6.16

Post by Cerulean Knight »

ochetski wrote:I asked because I did implemented a collision system with STI. But needed to set the tile sizes hard coded, because I wasn't able to get tiles width and height from the map.

My collision system is now ugly, complex and hard to use with multiple entities. I will probably change it to use love.physics. I will share it here as soon as I finish it.

Thanks Karai, please keep the good work because it will bring great games to life.
If you are using HardonCollider, you can add a few lines in the Map:getCollisionMap function.

So, the final result is this:

Code: Select all

function Map:getCollisionMap(index)
	local layer	= assert(self.layers[index], "Layer not found: " .. index)

	assert(layer.type == "tilelayer", "Invalid layer type: " .. layer.type .. ". Layer must be of type: tilelayer")

	local w		= self.width
	local h		= self.height
	local map	= {
		type		= layer.type,
		orientation	= layer.orientation,
		collision	= true,
		opacity		= 0.5,
		data		= {},
	}

	for y=1, h do
		map.data[y] = {}
		for x=1, w do
			if layer.data[y][x] == nil then
				map.data[y][x] = 0
			else
				map.data[y][x] = 1
				ctile = collider:addRectangle((x-1)*self.tilewidth, (y-1)*self.tileheight, self.tilewidth, self.tileheight)
				collider:setPassive(ctile) 
			end
		end
	end

	return map
end
Then, when you load a collision map, HC will create all invisible square on the map positions.

Note: collider is the variable that you define before

Code: Select all

collider = HC(100, on_collision,stop_collision)
Edit: changed size of tiles for variables.
Last edited by Cerulean Knight on Fri Mar 21, 2014 3:04 am, edited 1 time in total.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.6.16

Post by Karai17 »

It might be worth adding in HC hooks for those who want to use it with STI. Feel free to file a feature request on GitHub and I'll look into it.
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: No registered users and 2 guests