Random pick object -destroy eight surroung objects

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hi -
    I am designing a Windows (or HTML5) game with a grid of dots. The smallest grid is 6x6 and the largest will be 16x16. I want to be able to randomly pick a dot in the grid (I can), get it's x and y coordinates (I can) and finally, identify the 8 surrounding dots so I can flash them or destroy them. I can get the coordinates of the 8 surrounding objects by adjusting the X and Y coordinates of the target. I don't know how to translate those coordinates into the proper dots in the grid. I could use a blunt force approach for smaller grids (i.e. 6x6, 7x7) and write a routine for each individual dot. However, that is really tiresome when I get to the 16x16 grid (256 routines).
    In the game, a random dot is chosen in the grid. It starts flashing. If the player doesn't save the surrounding dots by the end of a set time, then the flashing dot and the 8 around it (or anythat are still adjacent) are lost. Not sure how to tackle this. Thanks for any suggestions and help offered.

    <span style="font-weight: bold"><span style="font-style: italic">'Til Later - RichC</span></span>

  • I'm not exactly sure if I understand what you're asking for here.
    I suppose you want to know how to identify the 8 surrounding dots of a random dot?

    First, you need to find a way to pick a random dot. The easiest way to do that is to use the "pick Dot at random" condition.
    Then one method is to simply position an object shaped as a square that overlaps all surrounding objects but the one in the middle, on the target object.
    Then do whatever you want with the objects overlapping the shape.

    Edited once, last by Popcorn (April 23, 2020 at 11:01 PM).

  • Okay. That sounds like a good trick to try. Thank you for your time and expertise. Stay safe.

    <span style="font-weight: bold"><span style="font-style: italic">'Til Later - RichC</span></span>

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!