Jump to content
IGNORED

Collision Detection Order


Recommended Posts

I was playing around with some code and when I had changed the order in a collision statement the effect seemed to be different. I don't think I had made any other changes in my program that would have made a difference because at the time I was just changing one line but I was wondering if something like 

 

if collision(playfield,player0) then...

 

Would behave differently than

 

if collision (player0,playfield) then...

 

 

Link to comment
https://forums.atariage.com/topic/327261-collision-detection-order/
Share on other sites

I don't think I've noticed a difference.  Although I have noticed a difference based on where in the main loop the collision checks are being made.  I've been making a collision detection section in my code that stores the results in a collision variable.  Each type of collision getting its own bit.  I can clear all 8 collision flags by just going "collided = 0" before starting the latest round of collision checking.

 def colp0p1 = collided{0}
 def colp0p2 = collided{1}
 def colp0p3 = collided{2}
 def colp0p4 = collided{3}
 def colp0p5 = collided{4}

This keeps the actual collision checks in one place for easier debugging.  But, maybe not the most efficient.

  • Like 1
1 hour ago, Gemintronic said:

I don't think I've noticed a difference.  Although I have noticed a difference based on where in the main loop the collision checks are being made.  I've been making a collision detection section in my code that stores the results in a collision variable.  Each type of collision getting its own bit.  I can clear all 8 collision flags by just going "collided = 0" before starting the latest round of collision checking.


 def colp0p1 = collided{0}
 def colp0p2 = collided{1}
 def colp0p3 = collided{2}
 def colp0p4 = collided{3}
 def colp0p5 = collided{4}

This keeps the actual collision checks in one place for easier debugging.  But, maybe not the most efficient.

I went back in my code and it didn't seem to act differently so maybe I just edited something else but I do notice sometimes it will behave a certain way located elsewhere, and not just before or after drawscreen. I like the variable idea.

 

What made me play around with this was I had originally had a collision detection with the playfield but then I swapped playfield and background and all the colors so that resulted in my changing the collision code since once the player would step out of the PF0 zone it wouldnt work like it did before. I ended up making 3 hit boxes for the area I originally had covered with the one collision check. I was just hoping to stick with the collision code since it was simpler but I like the change.

  • Like 1

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...