Jump to content
IGNORED

What is the best bounding box code for two 8x8 sprites?


Random Terrain

Recommended Posts

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.

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...