Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Collision with Tilemap Layer
#10
Some general advices:
  • when the intention of a function is to return a true/false value, define it as bool and return an explicit expression that evaluates to bool. test_direction() and detect_collision_area() have unclear intention, they return the numeric type of the tile but are treated as boolean.
  • logic of test_direction() is wrong. Implement it in a way that returns true only when all calls to detect_collision_area() return false, any positive in detect_collision_area() must return false. In layman terms: only allow motion if all testpoints are not colliding.
  • test_direction() has another problem, it only tests the corners of the character that are 32 pixels away, but tile size is 16 pixels. There are holes inside the character. Collision points must not be farther than 16 pixels. Insert an extra collision point in between.
Not repeating layers is not supported in tilengine, they always repeat. The effect you want can be easily implemented creating a thick solid border of empty tiles around your main map, and doing bound checking when trying to move.

Be safe you too!
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 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: 1 Guest(s)