I'm working on a sub-engine for handling sprite objects, and of course, I've come up to collision, and I'm kind of stuck. I know what I'm trying to do, I just need to think of a way that's much less sloppy and a lot faster. I'm constructing bounding boxes around each of the meta sprites, and I am going to keep track of the X/Y coordinates of each corner in RAM. The idea is to check if any of the bounding boxes are overlapping.
Right now, this is only for sprite to sprite collision. Sprite to BG collision detection is a lot easier, since I will be having a copy of what's on screen in RAM. I'll also be handling every object one at a time, so it's not too complicated for sprite to BG. I looked at the threads about collision here, and I came across a really good idea. Someone mentioned organizing coordinates from low to high to easily eliminate sprites that aren't colliding with whatever you're comparing it to. While this is a good idea, it seems that this is still an extremely long process.
It would take a really long time to compare every coordinate on one bounding box with every coordinate on another. The bad part about that is that's only for 2 objects. The main reason I think this is so complicated compared to BG collision is that I already have a copy of what metatiles are on screen in RAM. Those will ALWAYS be in a fixed 16x16 pixel location. If you check whether or not sprites are in the same 16x16 pixel feild, you can end up with collisions like Bugs Bunny's Birthday Blowout, where you hit the enemy and they're about 16 pixels away from you. So you pretty much have to do precise comparisons.
I feel like if I do all these comparisons, I'm wasting so much valuable time. I also feel like I'm going about doing things in a really sloppy way. Does anyone have any ideas on checking bounding box overlapping without wasting so much time? I'll be brainstorming ideas, but I just wanted to know what everyone else thinks.
Right now, this is only for sprite to sprite collision. Sprite to BG collision detection is a lot easier, since I will be having a copy of what's on screen in RAM. I'll also be handling every object one at a time, so it's not too complicated for sprite to BG. I looked at the threads about collision here, and I came across a really good idea. Someone mentioned organizing coordinates from low to high to easily eliminate sprites that aren't colliding with whatever you're comparing it to. While this is a good idea, it seems that this is still an extremely long process.
It would take a really long time to compare every coordinate on one bounding box with every coordinate on another. The bad part about that is that's only for 2 objects. The main reason I think this is so complicated compared to BG collision is that I already have a copy of what metatiles are on screen in RAM. Those will ALWAYS be in a fixed 16x16 pixel location. If you check whether or not sprites are in the same 16x16 pixel feild, you can end up with collisions like Bugs Bunny's Birthday Blowout, where you hit the enemy and they're about 16 pixels away from you. So you pretty much have to do precise comparisons.
I feel like if I do all these comparisons, I'm wasting so much valuable time. I also feel like I'm going about doing things in a really sloppy way. Does anyone have any ideas on checking bounding box overlapping without wasting so much time? I'll be brainstorming ideas, but I just wanted to know what everyone else thinks.