Per-pixel collision problem in C#

后端 未结 3 1533
猫巷女王i
猫巷女王i 2021-01-16 05:33

I am writing a small 2d game engine in C# for my own purposes, and it works fine except for the sprite collision detection. I\'ve decided to make it a per-pixel detection (e

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-16 06:15

    I don't think many people here will bother to scrutinize your code to figure out what exactly is wrong. But I can come with some hints to how you can find the problem.

    If collision happens long before it is supposed to I suggest your bounding box check isn't working properly.

    I would change the code to dump out all the data about rectangles at collision. So you can create some code that will display the situation at collision. That might be easier than looking over the numbers.

    Apart from that I doubt that per pixel collision detection easier for you to implement. When you allow for rotation and scaling that quickly becomes difficult to get right. I would do polygon based collision detection instead.

    I have made my own 2D engine like you but I used polygon based collision detection and that worked fine.

提交回复
热议问题