04-14-2020, 04:35 AM
(04-14-2020, 03:36 AM)megamarc Wrote: Hi,
You're experiencing two unrelated problems:
1. Seems that TLN_GetTileInfo() is not correctly protected against passing negative values as world coordinates, that's why sometimes "segfaults" when walking left and up. I should protect it, menawhile you can do it in your application, checking against negative values and if so, adding the size of the negative dimension. You can get them at runtime with TLN_GetLayerWidth() and TLN_GetLayerHeight().
2. Bad detection: you forgot to initialize city->initx and city->inity to 0 at startup, they have undefined values you're setting up the starting position of the layer with these unknown values. That's why what you see is not what you expect, you're checking in one place but displaying another. Setting them to 0 and then calling TLN_SetLayerPosition() will fix it.
I have fixed the issues but the detection is still bad. The player can go into the left side of the wall while the right it is correct, and just generally clip. I should look into better tackling of the problem but currently this is what stands. I would love to know how to do a bounding box sort of thing so it's way more intuitive to have a place where you can't collide with. Generally I am doing a "world moves, not player" sort of thing which is easier to program but less intuitive to account for in these scenarios. Lemme know!
![[Image: unknown.png]](https://cdn.discordapp.com/attachments/663606741660860421/699325483908857916/unknown.png)
![[Image: unknown.png]](https://cdn.discordapp.com/attachments/663606741660860421/699325535918096434/unknown.png)
![[Image: unknown.png]](https://cdn.discordapp.com/attachments/663606741660860421/699325681175101500/unknown.png)
I wish you could just mov the obstacle from the destination.