How do I make a Array Selection?

0 favourites
  • 11 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • Hey Constructors.

    I want to make a selection in my array over serval coherent numbers. I need to make a circular selection, so I plotted in this tedious selection of numbers.

    ..There Must be a smarter way around this, right? A selection mode or math equation?

    Thanks! :)

  • Seems fine? As long as it's a reusable function and you don't keep pasting those actions everywhere.

  • It works alright but it is tedious, and I would like to have has better control over the selection so I could adjust the selection during a fx. 'For Each" runtime. Would make a 'drunken man' map generation much more interesting I believe.

  • It works alright but it is tedious, and I would like to have has better control over the selection so I could adjust the selection during a fx. 'For Each" runtime. Would make a 'drunken man' map generation much more interesting I believe.

    Sorry I don't know what any of that means :D

  • Ok, sorry.

  • You could try this:

    Add a variable n, where n is equal to the max distance in the x or y direction that you want to change; in your example it would be 2.

    For "i" from -n to n

    For "j" from -n to n

    ->If loopindex("i") + loopindex("j") <= n, Set value at Xspawn+loopindex("i"),Yspawn+loopindex("j") to 1

    Set value at (Xspawn,Yspawn) to 16

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ahh, that's a good idea mate, thanks a whole lot. :)

  • You could try this:

    Add a variable n, where n is equal to the max distance in the x or y direction that you want to change; in your example it would be 2.

    >For "i" from -n to n

    >For "j" from -n to n

    ->If loopindex("i") + loopindex("j") <= n, Set value at Xspawn+loopindex("i"),Yspawn+loopindex("j") to 1

    >Set value at (Xspawn,Yspawn) to 16

    That worked out really nice mate. Thank you!

  • You're welcome :-)

  • I put together a demo that will fill an ellipse of tiles around a point, it should work better than the example I gave above:

    dropbox.com/s/tv6nk0b7rmd0w8l/tileFillRange.c3p

  • Beautiful, that is a tight efficient solution. Thanks again mate! :D

    If you struggle with something graphical, then PM me and I will offer my service.

    Have a great day. :)

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