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.9.2

Post by Karai17 »

Thanks for the report! I think the best solution would be to ensure animated tiles have all the same properties as static tiles. I'll look into this.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Clean3d
Prole
Posts: 30
Joined: Fri Mar 29, 2013 4:16 pm

Re: Simple Tiled Implementation - STI v0.9.2

Post by Clean3d »

A few more questions :P
  • I'm trying to make certain layers with collision-enabled tiles not generate collisions in the world. From looking at the source, it seems I should be able to do this by adding a property "collidable" to the layer and setting it to "false", but this doesn't work. Am I missing something?
  • I also don't understand how the collidable property get added to the layers in the first place. It's not in the maps I've made, and I don't see it being assigned in the source code.
  • Does drawWorldCollision not support polylines? I have some tiles with just a single two-point polyline defining their edge, and when I tried to implement drawWorldCollision I got this error:

    Code: Select all

    Error: lib/Simple-Tiled-Implementation/map.lua:928: Need at least three vertices to draw a polygon
    
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.9.2

Post by Karai17 »

1) There is currently no way to override the collision. If something is collidable, it's going to generate. Feel free to file a feature request!

2) You need to manually add it to the properties in Tiled.

3) It should be able to draw polylines. Check the demo in the OP, I believe I have 4 polylines set up to stop the player from leaving the map.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Clean3d
Prole
Posts: 30
Joined: Fri Mar 29, 2013 4:16 pm

Re: Simple Tiled Implementation - STI v0.9.2

Post by Clean3d »

Thanks for the quick reply!

1/2) Oh! The demo explains a lot. I didn't know you could define simple collision shapes with the property like that, so I misunderstood what collidable was for. Cool feature, though.

For my own game, it would be easy enough to make STI check an "ignoreCollisions" property, but I'm not sure whether that's useful enough to submit a pull request for.

3) In the OP-linked demo, if I define a two-point tile collision shape on one of the tiles then I can reproduce the crash. It appears to be because framework.polygon (for Love2D) only wants to draw closed shapes that have 3+ verts. I'm trying to find out now whether I can test during map:drawWorldCollision and use a different draw function for polylines that a) aren't closed or b) have fewer than 3 verts.
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.9.2

Post by Karai17 »

While I think a "false" override would be useful, it would be quite difficult to implement considering the current way "true" works. It would also be neat if you could arbitrarily turn collisions on and off, but I believe that's out of scope of how Box2D works. You'd need to get the handle for the specific collidable body and destroy it, and there is no simple way to manage that inside of STI. STI's built-in collision is quite static and I think it should remain that way. However, you are not limited to using STI's collision and if you find it inadequate for your specific needs, there is no reason why you cannot build your own collision world using the STI data.

Yeah, thinking back the polyline I was referring to is actually a polygon. I should probably stick a fix in there that would check how many vertices we have, and draw a polyline if it is < 3.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
bcvery1
Prole
Posts: 5
Joined: Wed Nov 12, 2014 11:18 am

Re: Simple Tiled Implementation - STI v0.9.2

Post by bcvery1 »

It was recommended I post my question here as "it seems to be an issue with the library".

I'm new to LOVE2d and I'm trying to make a player icon move across a simple map. I've been following the tutorials on the wiki, and the API and I've run into a problem with drawing a range of the map. If I do not use map:setDrawRange... the whole map displays fine; however with that line in the map cuts off early (see attached images).

The map is a .lua file, made with tiled 0.10.2; it has one tiled layer. I'm running LOVE version 0.9.1 (Baby Inspector).

I have attached the .love file also.


Many thanks,
BC
Attachments
Just a little to the right
Just a little to the right
after.png (4.78 KiB) Viewed 4797 times
Map showing correctly
Map showing correctly
before.png (4.84 KiB) Viewed 4797 times
map2.love
(23.95 KiB) Downloaded 335 times
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.9.2

Post by Karai17 »

Map:setDrawRange() takes in the same translation as love.graphics.translate. You were also subtracting player_init_* instead of adding it.

Code: Select all

function love.draw()
  local player = map.layers["Sprite Layer"].sprites["player"]
  local tx = -player.x+player_init_x
  local ty = -player.y+player_init_y

  love.graphics.push()
  love.graphics.translate(tx, ty)
  map:setDrawRange(tx, ty, windowWidth, windowWidth)
  map:draw()
  love.graphics.pop()
  
  love.graphics.setColor(0, 127, 255, 255)
  love.graphics.print(math.floor(player.x)..", "..math.floor(player.y), 20, 20)

  love.graphics.setColor(255, 255, 255, 255)
end
See also: http://karai17.github.io/Simple-Tiled-I ... Range.html

I'm curious, which tutorials were you reading?
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
bcvery1
Prole
Posts: 5
Joined: Wed Nov 12, 2014 11:18 am

Re: Simple Tiled Implementation - STI v0.9.2

Post by bcvery1 »

Thank you Karai17! Now I see what you've suggested, the solution seems obvious
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: Simple Tiled Implementation - STI v0.9.2

Post by Jeeper »

Btw, a while back you said that you added support for animated tiles. I have looked a bit in the documentation, but could not find anything. How do you created animated tiles?
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.9.2

Post by Karai17 »

Tiled supports animated tiles natively, so do it in Tiled and it'll work in STI.
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