Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Collision with Tilemap Layer
#5
(04-13-2020, 02:59 PM)megamarc Wrote: A boolean "Collidable" would be impractical, as there are many types of collisions: is the block solid walkable floor? One-way platform? A ladder?  Sliding slope? Dangerous spikes? All of them are collidable but must behave differently.

Currently up to version 2.4.x, Tilengine reads a custom property called "type" in the tileset. It is numeric in type, and is the value returned in TLN_TileInfo::type structure member (http://www.tilengine.org/doc/struct_t_l_..._info.html). The example project SuperMarioClone uses this system to determine the type of tile, if you open the file smw_foreground.tsx you will see it.

Since I implemented this feature, the Tiled editor has had the standard property Type added to the tilleset. In a future update that I am preparing, it will also bring this property to get the type, although I will leave the current custom property for backwards compatibility. You can even see this parameter unused in your screenshot, just below ID.

There are other gameplay implementations that use a layer exclusively for collisions, in which there are as many different tiles as there are collidable block types, and it uses the tile ID as a type. It is a bit redundant, and although it can be done it is preferable to work directly with the "type" property in the main tileset:
https://ansimuz.itch.io/sunnyland-forest

I have managed to get it working now, but my implementation seems wonky at best. I can't seem to hit well geometry and in some instances getting collisions close to the 0,0 coordinate can result in a segfault! Here is my code as it currently is. I don't know how I can correctly test with tiles... I have been making use of the fixed point stuff too which resulted in a few moments I forgot to convert to int hah. I should pay more attention!


Attached Files
.zip   rpg.zip (Size: 8.74 KB / Downloads: 3)
I wish you could just mov the obstacle from the destination.
Reply


Messages In This Thread
RE: Collision with Tilemap Layer - by megamarc - 04-11-2020, 04:37 PM
RE: Collision with Tilemap Layer - by megamarc - 04-13-2020, 02:59 PM
RE: Collision with Tilemap Layer - by Uneven_Prankster - 04-13-2020, 11:20 PM
RE: Collision with Tilemap Layer - by megamarc - 04-14-2020, 03:36 AM
RE: Collision with Tilemap Layer - by megamarc - 04-14-2020, 02:45 PM
RE: Collision with Tilemap Layer - by megamarc - 04-17-2020, 05:08 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)