[Solved] Overlapping Blocks in 2D Mining Game

So recently, I’ve been trying to make a 2D procedual generation mining game, each time you mine a block, other blocks appear around it, creating a seamlessly infinite cave, the problem is that rocks are spawning over other rocks and trying to check for collisions isn’t working, here’s the code I’m using and how the game looks:


image
On this image there are 2 coal blocks, but when I mine the rock below it the new one goes on top of it:
image

Your issue is that you are selecting the pedra object that is under the cursor (which should also be the one closest to the cursor). At this point, GDevelop is working with only the one pedra in the subevents. So any collision checks are done with that one pedra object.

To resolve this, I would look at a slightly different approach:

  1. Set BlocoX and BlocoY to the centre point of pedra
  2. Instead of repositioning the blue blocks (debugBlocoBaixo), create 4 new ones around the mined block. This can be done in one event with 4 actions.
  3. Create a new event to check for collision between pedra and debugBlocoBaixo, and delete debugBlocoBaixo (this will only delete the debugBlocoBaixo colliding with pedra.
  4. Then add a “Repeat for each debugBlocoBaixo object” event, with actions that create a pedra object
  5. Finally add an event with action that deletes debugBlocoBaixo.
1 Like

Ok, I will try doing that, it’s great you could help me even I though I used another language, I will update you if it worked! Thanks!

No way it worked, I’ve spent hours trying to fix it and you found such a simple solution, thank you

1 Like