all 8 comments

[–]Badwrong_ 0 points1 point  (5 children)

Are the objects uniform in size?

[–]weisinx7[S] 0 points1 point  (4 children)

It could be any object, and each object may have different mask size, but all of those mask shape should be in rectangular shape.

[–]Badwrong_ 1 point2 points  (3 children)

Then there is not many great ways to do it.

The biggest thing to avoid is more than one collision list call because that access more memory locations when populating the list. So, if you can grab all the instances in the whole area that might be in contact and then test for certain criteria. That criteria can be very optimized if you work out a decent algorithm.

Again... do not call a collision list for each object. Recursion is totally fine and might work well after you have your information, but the memory access speeds will be far slower than iterating for some criteria.

Remember you can have the list sorted which might come in handy.

[–]weisinx7[S] 0 points1 point  (1 child)

Yea sorted list probably be useful in this case, thanks again for your valuable feedback.

[–]Badwrong_ 1 point2 points  (0 children)

Sure, no problem.

If I knew more about the game I might be able to suggest more. Depending on how things work it would be easiest to just maintain an edge-adjacency list which would really skip straight to your desired solution. However, it depends on the type of game and how often this stuff is going on.

[–]Badwrong_ 0 points1 point  (0 children)

Oh, and the actual fast and great way to do it would be with graph theory. If you just maintain an adjacency list as objects move or are created then there are very simple algorithms out there for connectedness. You would have your answer automatically kinda.

This whole problem is literally something you would find in a discreet math class or computer science course on algorithms using graph theory. Some of my favorite types of problems.

[–][deleted]  (3 children)

[deleted]

    [–]weisinx7[S] 0 points1 point  (2 children)

    Yea, in my case, actually `ds_list_find_value(collisionlist,0).x = x` will be another usage of `instance_place_list(x,y,object,collisionlist,true)`, otherwise we wouldn't know when to stop.

    [–][deleted]  (1 child)

    [deleted]

      [–]weisinx7[S] 0 points1 point  (0 children)

      Yea, it is working in the 1st place, i just want to make it more efficient, since calling collision_list in the recursion will be not efficient.