Simple Tiled Implementation - STI v1.2.3.0

Showcase your libraries, tools and other projects that help your fellow love users.
ochetski
Prole
Posts: 3
Joined: Thu Mar 20, 2014 9:46 pm

Re: Simple Tiled Implementation - STI v0.6.16

Post by ochetski »

Karai17 wrote:You should be able to access map.tilewidth and map.tileheight without any problem.
Oh, I don't noticed that, Karai. I was looking for the size somewhere with collision map type, orientation, collision and so.
Cerulean Knight wrote:
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 (if you are using 32x32 tiles):

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)*32, (y-1)*32, 32, 32)
				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)
That's what I will do, but I'm really thinking about use love.physics. And keep it apart from STI to keep things easy to update.
Thanks!
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 »

It will be great when in tiled we can edit the collisions in each tile. In the 9/03 daily version it's avalaible, but it is not exported into lua.
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 »

Built in collision? Can you explain more?
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 »

It's on the 9/03 daily version of tiled.

Image

And here is the new part of the tmx file:

Code: Select all

<tile id="32">
   <objectgroup draworder="index">
    <object x="32.625" y="31.125">
     <polyline points="0,0 -0.25,0.5"/>
    </object>
    <object x="13" y="0" width="18.75" height="31.875"/>
   </objectgroup>
  </tile>
  <tile id="43">
   <objectgroup draworder="index">
    <object x="0.125" y="0" width="22" height="31.875"/>
    <object x="22.125" y="13.375" width="9.75" height="18.5"/>
   </objectgroup>
  </tile>
 </tileset>
The 32 had a polygon point by point (looks like I'll never use it), and the 43 had 2 rectangles, but It is not exported to lua yet.

This editor and animation will be great in the next version (:


Edit: Oh, I noted that animations are exported.

Code: Select all

<tile id="43">
   <objectgroup draworder="index">
    <object x="0.125" y="0" width="22" height="31.875"/>
    <object x="22.125" y="13.375" width="9.75" height="18.5"/>
   </objectgroup>
   <animation>
    <frame tileid="9" duration="100"/>
    <frame tileid="33" duration="100"/>
    <frame tileid="37" duration="100"/>
   </animation>
  </tile>
 </tileset>

Code: Select all

tiles = {
        {
          id = 43,
          animation = {
            {
              tileid = "9",
              duration = "100"
            },
            {
              tileid = "33",
              duration = "100"
            },
            {
              tileid = "37",
              duration = "100"
            }
          }
        }
blkducky
Prole
Posts: 2
Joined: Wed Mar 26, 2014 9:39 pm

Re: Simple Tiled Implementation - STI v0.6.16

Post by blkducky »

So does this just not support tiles in object layers yet?

Image

Left is LÖVE window, right is Tiled. The rectangle object is on the same layer as the stuff on the table but obviously only the rectangle appears.
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 »

Can you post a .love so I can examine the map file(s)?
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
blkducky
Prole
Posts: 2
Joined: Wed Mar 26, 2014 9:39 pm

Re: Simple Tiled Implementation - STI v0.6.16

Post by blkducky »

Minimum code needed to replicate it. It just never draws tile objects for me.

(LÖVE 0.9.0, Tiled v0.9.1 - daily build from a few days ago)
Attachments
Minmap.love
(6.48 KiB) Downloaded 128 times
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.7.2

Post by Karai17 »

Sorry for the very late reply. I'm going to be poking at STI tonight so hopefully I can get this sorted out.

Edit: STI now has support for non-LOVE frameworks, though none are built yet. If anyone wants to extend it, please push your changes upstream!

Edit 2: STI now draws to canvas before drawing to screen, this should fix some graphical glitches when scaling a map.

Edit 3: Removed dependency for LuaJIT's bitwise operations. :)
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.7.4

Post by Karai17 »

Fixed a couple bugs~
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
danbo
Prole
Posts: 18
Joined: Thu Jan 03, 2013 8:11 pm

Re: Simple Tiled Implementation - STI v0.7.4

Post by danbo »

Used this for Ludum Dare, much nicer to get off the ground with than ATL.

The double-step of having to export as lua table is a little irritating, but it's a price I happily paid.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest