Select Nearest Sprites

  • Here you go:

    https://www.dropbox.com/s/arks1fjcc1mu5 ... .capx?dl=0

    The code is not optimized, but it works.

  • Try Construct 3

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

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

    You’d have to measure the speed to see which is faster. I was going for a simple solution with a minimal amount of used features. It’s only done once per click so even if it’s slowish it’s ok imo. That said I haven’t had a chance to look in the capx files to see what is different. For max speed you’d utilize an array but I’m like dop, I think it makes things ugly.

    You seem to have landed on a fun problem to solve, always a good thing.

  • AnD4D

    Haa I new Something will be no right, I thought you wanna follow the source where the Flood bigging, I miss understood this statement

    [quote:1eznd0l3]

    having the flooded parts remain in a second click, but spreading. By that, I mean, say you're using a flood of 5. When you click on a tile, 5 other tiles are highlighted.

    I fixed for you

    https://www.dropbox.com/s/x97zzeeoyt8dxtp/LimitedFlood_2.capx?dl=0

  • Here you go:

    https://www.dropbox.com/s/arks1fjcc1mu5 ... .capx?dl=0

    The code is not optimized, but it works.

    AnD4D

    Haa I new Something will be no right, I thought you wanna follow the source where the Flood bigging, I miss understood this statement

    [quote:1seoeqpc]

    having the flooded parts remain in a second click, but spreading. By that, I mean, say you're using a flood of 5. When you click on a tile, 5 other tiles are highlighted.

    I fixed for you

    https://www.dropbox.com/s/x97zzeeoyt8dxtp/LimitedFlood_2.capx?dl=0

    This was really fun. My final version is very similar to dop2000, but strangely no where near as fast, nor efficient.

    Strangely enough, I'm noticing some unusual results. If you place a flood of 20 down somewhere, then change the flood number to 1, and click on one of the tiles, it'll seemingly change a tile in a random place, rather than one that is nearby.

    tarek2 Your version seems pretty much perfect. I'm going to play around with it a little bit more, as I'm quite attached to Dop's version <img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing">

    I really appreciate people helping me out with stuff like this. I'm likely to come up with more in the near future, as I'm trying out lots of little experiments <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

  • I haven't looked at any of the examples, but I think the "pick closest" would work for a fill if you worked it like a stack.

    You would iterate all the sides "pick closest" x+1,y+1,x-1,y-1, compare the distance, and put picks on the variable stack.

    If there were no match's pop the top of the stack.

    goto 1

  • tarek2 Took me a while to understand the code. I couldn't see where you were inputting the range, but now see that you are doing it using the line of sight behaviour, which is very clever indeed. I didn't even consider doing that. Great stuff!

  • tarek2 Took me a while to understand the code. I couldn't see where you were inputting the range, but now see that you are doing it using the line of sight behaviour, which is very clever indeed. I didn't even consider doing that. Great stuff!

    Hahha I can imagine hunting for that hiding part lol

    Thank you, That's a little trick I use when I don't want to use the Overlap is very helpful and limits the Los Range for performance, what I notice in all my experiments with Line of Sight is the more you turn up the Range the more expensive it becomes even if is not in use by the events

    I'm Glad, you like it, was really fun Puzzle to solve, if you have any questions that you don't understand in my Capx you can always ask me

  • > tarek2 Took me a while to understand the code. I couldn't see where you were inputting the range, but now see that you are doing it using the line of sight behaviour, which is very clever indeed. I didn't even consider doing that. Great stuff!

    >

    Hahha I can imagine hunting for that hiding part lol

    Thank you, That's a little trick I use when I don't want to use the Overlap is very helpful and limits the Los Range for performance, what I notice in all my experiments with Line of Sight is the more you turn up the Range the more expensive it becomes even if is not in use by the events

    I'm Glad, you like it, was really fun Puzzle to solve, if you have any questions that you don't understand in my Capx you can always ask me

    I do have one question, actually.

    If I look at the tile in debug during a test; if the selection number = 1, and I click on it, it doesn't change the instance boolean "Checked" to true (1). However, if I pick a higher selection number, such as 5, and then click the exact same tile, it will change the check boolean to true.

    Do you know why that is? Is that important? When I try to change the code so that it will allow such a thing to happen, things start breaking.

  • >

    > > tarek2 Took me a while to understand the code. I couldn't see where you were inputting the range, but now see that you are doing it using the line of sight behaviour, which is very clever indeed. I didn't even consider doing that. Great stuff!

    > >

    >

    > Hahha I can imagine hunting for that hiding part lol

    >

    > Thank you, That's a little trick I use when I don't want to use the Overlap is very helpful and limits the Los Range for performance, what I notice in all my experiments with Line of Sight is the more you turn up the Range the more expensive it becomes even if is not in use by the events

    >

    > I'm Glad, you like it, was really fun Puzzle to solve, if you have any questions that you don't understand in my Capx you can always ask me

    >

    I do have one question, actually.

    If I look at the tile in debug during a test; if the selection number = 1, and I click on it, it doesn't change the instance boolean "Checked" to true (1). However, if I pick a higher selection number, such as 5, and then click the exact same tile, it will change the check boolean to true.

    Do you know why that is? Is that important? When I try to change the code so that it will allow such a thing to happen, things start breaking.

    AnD4D you right I didn't count on that Possibility of one single Tile selected at the start of the Game I always counted with one Tile+

    This problem would only happen if the first Tile selected at the start of the Game is only one anything more than one it wouldn't have that problem only happens if is the first tile of the Game selected, if the game was already started and you change to select 1 tile only it wouldn't have that problem as the tiles already active will take care of that

    You can Easly fix this problem by adding one more action on Event 5

    Sprite >>set Checked To True

    That will fix it, I can comment the capx if you like if you have any trouble understanding how it works just let me know

  • AnD4D

    Here is another Capx, I removed some Global Variables and changed the way the Loop stops at the End of the Game, I didn't check everything 100% so you may find something that I missed

    https://www.dropbox.com/s/4epggm9jh4ojswy/LimitedFlood_4.capx?dl=0

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