Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
error doing image collision detection with _MemGet
#28
That really made me want to dig into collisions.

1st challenge: handle collisions for objects that are longer than they are wide.
2nd challenge: detect collisions before they happen using ray tracing.

But first, a short debrief of how my proximity-and-mask-overlap collision detection code works.

- All objects (shapes) are built to fit inside a circle with a predefined maximum radius.
- Space is divided into square areas whose side length equals the maximum radius.
- At any given moment an object will overlap at least 1 area and at most 9 areas.
- If an area is overlapped by several objects, the distance between the centers of those objects is computed pairwise.
- If the calculated distance is less than or equal to 2 times the maximum radius, the masks of the two objects are copied into an image buffer the size of the area, placed according to their actual positions relative to that area.
- Since the masks are semi‑transparent, overlapping pixels become opaque.
- If the resulting image buffer contains at least one opaque pixel, a collision is confirmed for both objects.
- Pairs of objects already detected as colliding do not need to be detected again.

I made two improvements (code updated in post #21):
1. Because an object’s mask must be recalculated every cycle due to the object rotating, the mask is now recomputed for an object only when a collision is suspected.
2. For better performance, detection precision can now be reduced by changing mask size with the PIXELS_PRECISION parameter. A mask’s area is divided by PIXELS_PRECISION squared.
Reply


Messages In This Thread
RE: error doing image collision detection with _MemGet - by Herve - 09-18-2025, 08:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Collision Detection NakedApe 12 306 02-26-2026, 01:01 AM
Last Post: NakedApe
  Mac debugger not connecting, a user error! BlameTroi 0 99 02-07-2026, 06:18 PM
Last Post: BlameTroi
  ERROR MESSAGES COLORS ? aurel 5 384 01-02-2026, 11:26 AM
Last Post: aurel
  Using CONST & _RGB used together seem to error... Dav 12 685 12-12-2025, 12:29 AM
Last Post: Dav
Photo from png tile, create symmetrical screen image hsiangch_ong 11 932 08-23-2025, 01:23 AM
Last Post: bplus

Forum Jump:


Users browsing this thread: 1 Guest(s)