Hi guys. I've been looking in the toolchain documents for a little while now, and I can't find any intersect function. An example is if two sprites touch each other. I am trying to program a breakout game, but I can only program it in java right now because of the intersect function in java. Is there anything like this in the C toolchain? Thanks for any help.
Can you describe what needs to be intersected?
Sorry I don't know much about java, or it's intersect function. But I might me able to make some code to do the detection for you. I don't know if you actually mean for the sprites to intersect or if you mean for it to detect collision...
https://ce-programming.github.io/toolchain/graphx_8h.html#a65e4e81be0b5a48b50f3baeb621b24a9
NonstickAtom785 wrote:
Can you describe what needs to be intersected?
Sorry I don't know much about java, or it's intersect function. But I might me able to make some code to do the detection for you. I don't know if you actually mean for the sprites to intersect or if you mean for it to detect collision...


In a breakout game, the collision detection that is needed is the ball and the bricks.
dunlavdy wrote:
NonstickAtom785 wrote:
Can you describe what needs to be intersected?
Sorry I don't know much about java, or it's intersect function. But I might me able to make some code to do the detection for you. I don't know if you actually mean for the sprites to intersect or if you mean for it to detect collision...


In a breakout game, the collision detection that is needed is the ball and the bricks.


Hmm. Maybe a pixle-test collision detection can be used. Are you using some type of array?
What exactly are you trying to do?
If you want to check if two objects are colliding, it's almost always more efficient to approximate the shape of the objects using rectangular boxes, circles, or polygons.
If you want to see if two rectangular regions are intersecting, you should use axis-aligned bounding boxes.
If you want to see if a point is inside a rectangle, you should use gfx_CheckRectangleHotspot.
If you want to see if two circular regions are colliding, you should see if the distance between the two is less than their radii added together.
If you absolutely need to check if any non-transparent pixel on one sprite overlaps any non-transparent pixel on another sprite, you should do a rough phase using AABBs, finding the area of the screen where the rectangular area of the sprites overlaps. Then, you would iterate through each pixel in that area and check the pixels of each sprite. If both of them are not the transparent index, then the two sprites overlap. This method will probably be incredibly slow.

There's no point for this to be in graphx, in my opinion, as this isn't a graphics function but a collision one.
https://stackoverflow.com/questions/13390333/two-rectangles-intersection
commandblockguy wrote:
What exactly are you trying to do?
If you want to check if two objects are colliding, it's almost always more efficient to approximate the shape of the objects using rectangular boxes, circles, or polygons.
If you want to see if two rectangular regions are intersecting, you should use axis-aligned bounding boxes.
If you want to see if a point is inside a rectangle, you should use gfx_CheckRectangleHotspot.
If you want to see if two circular regions are colliding, you should see if the distance between the two is less than their radii added together.
If you absolutely need to check if any non-transparent pixel on one sprite overlaps any non-transparent pixel on another sprite, you should do a rough phase using AABBs, finding the area of the screen where the rectangular area of the sprites overlaps. Then, you would iterate through each pixel in that area and check the pixels of each sprite. If both of them are not the transparent index, then the two sprites overlap. This method will probably be incredibly slow.

There's no point for this to be in graphx, in my opinion, as this isn't a graphics function but a collision one.


Thank you commandblockguy! You always seem to have a perfect answer. And thanks Mateo, that function will help a ton.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement