+Random Terrain Posted October 5 Share Posted October 5 I'm working on a DPC+ program and can't rely on normal collision detection since there is a third sprite on the screen. What is the fastest/smallest bounding box code for two 8x8 sprites that simply uses an if-then or two? I'd like to avoid using data. The code below seems to be working so far, but I don't know if it's the best code to use: if !collision(player0,player1) then goto __Skip_Player_Death if player1x < (player0x+8) && (player1x+8) > player0x && player1y < (player0y+8) && (player1y+8) > player0y then goto __P0_P1_Collision Thanks. 1 Quote Link to comment Share on other sites More sharing options...
+Karl G Posted October 5 Share Posted October 5 I'm afraid that your code is as simple as it gets for a box collision like this. 🙂 RevEng posted an assembly "boxcollision" function for bB taken from 7800BASIC that you could use. I don't know if it would be less cycles or not since you also have the overhead of a function call if you use that code. 1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted October 5 Author Share Posted October 5 3 hours ago, Karl G said: I'm afraid that your code is as simple as it gets for a box collision like this. 🙂 RevEng posted an assembly "boxcollision" function for bB taken from 7800BASIC that you could use. I don't know if it would be less cycles or not since you also have the overhead of a function call if you use that code. Thanks. I tried all kinds of things that didn't work, quit and played an Xbox game for a while, then that code popped into my head. I don't even know if it works right in all cases, but it seems to be working somehow. If nobody sees a problem with the code I posted, I guess I'll just stick with that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.