Page 27 of 92

Re: Simple Tiled Implementation - STI v0.9.2

Posted: Sun Nov 09, 2014 2:15 am
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.

Re: Simple Tiled Implementation - STI v0.9.2

Posted: Mon Nov 10, 2014 6:21 pm
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
    

Re: Simple Tiled Implementation - STI v0.9.2

Posted: Mon Nov 10, 2014 6:50 pm
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.

Re: Simple Tiled Implementation - STI v0.9.2

Posted: Mon Nov 10, 2014 8:53 pm
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.

Re: Simple Tiled Implementation - STI v0.9.2

Posted: Mon Nov 10, 2014 10:04 pm
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.

Re: Simple Tiled Implementation - STI v0.9.2

Posted: Wed Nov 12, 2014 4:24 pm
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

Re: Simple Tiled Implementation - STI v0.9.2

Posted: Wed Nov 12, 2014 8:02 pm
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?

Re: Simple Tiled Implementation - STI v0.9.2

Posted: Thu Nov 13, 2014 11:48 am
by bcvery1
Thank you Karai17! Now I see what you've suggested, the solution seems obvious

Re: Simple Tiled Implementation - STI v0.9.2

Posted: Mon Nov 17, 2014 7:44 pm
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?

Re: Simple Tiled Implementation - STI v0.9.2

Posted: Mon Nov 17, 2014 10:24 pm
by Karai17
Tiled supports animated tiles natively, so do it in Tiled and it'll work in STI.