Bubble shooter: ball colisions placement

  • Hello there,

    does anybody have experience with that?

    The problem: how to calculate precise bubble position on the hex-grid?

    What I already tired:

    1) Bullet behavior: on collision with bubble, position at y-1 of the collided bubble. This works but not always and not precise.

    2) Trying to calculate the position of the ball before shooting, by drawing a ray, which reflects from vertical walls and than collides with bubbles on the grid. Basically the same problem here, because it is collision dependent.

    Any ideas how to solve it without using collision detection?

  • Here's a bubble shooter test that I made a while back:

    dropbox.com/s/pjj587iygha5mz9/bubble_shoot.capx

    It's not complete but it does have the motion, snapping to grid and locating unconnected bubbles implemented.

  • Wow, that's clever - thank you.

    So you basically use while loops for moving them -1px back to the right position at an angle until it doesn't overlap anymore and than snap it. Interesting technique.

    Man, your logic for locating unconnected bubbles just made me speechless - I would never think this way.

  • Hi R0J0hound,

    I was trying to take a look from your example but the link is death, could you share it again??

    Thanks,

  • Hi R0J0hound,

    Is it possible to get that example.

    As the link is dead.

    Thanks

  • link updated

  • R0J0hound

    Thanks you so much!

    Just wanted to know.

    when snap instance boolean is true you have defined odd instance to (int((self.Y-16)/28)%2)*16

    16 must be the half of the ball size not able to understand 28 number?

  • It’s been ages since I derived that formula so I don’t know other than it is related to the ball size.

    Basically place the balls down manually, then calculate the y difference between two rows. It actually would come out to 16*sqrt(3) which is about 27.6 but I just rounded to 28 to be able to snap to integer positions.

    I calculated it by placing two balls on one row and one ball between them on the next. Draw a triangle between the centers. Each side is 32. Cut the triangle in half. The horizontal side is 16, the diagonal side is 32 and we can calculate the vertical side with the Pythagorean theorem. a^2+b^2=c^2 where a=16, c=32 and just solve for b

  • Yeah every other row, set the tile x to the tile width + 1/2 tile width worked for me.

    Still might be a good idea to have a plug to do hex calculations. Of course the question is if it should be in the tilemap plug.

  • Plugins seem like an overkill for something like this.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • R0J0hound

    Thank you so much for the explanation

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)