How do I detect and change isolated/encircled groups of values in an array?

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Isolated Ambience Loops is a cross genre sound library of loops for creating unique sound beds and background tracks.
  • (Sorry for asking so many questions over the past few days; I'm participating in a game jam and working on a pretty technically complex project for it by my standards)

    Anyway, I am trying to write a function to find 'encircled' clusters of values in an array, and change their value. In this case, I want to find relatively small groups of spots in a array with the value 1 that are surrounded by 0 and change the group of 1s to 3s. There is absolutely no way I could possibly explain what I tried with screenshots, so I'll link the file below (the main code in question is in the Frontline group functions "FindEncirclements" and "FloodFillBlue").

    I'm not sure if I just messed up one or two events, or if there is an entirely diffrent system that I should be using, but either way it would help a ton to have a fresh pair of eyes look at this.

    https://drive.google.com/file/d/1fQeMQSXBY8Hs90i8WKGVr4unMTMIPDrA/view?usp=drive_link

  • I can't help you with the array, but there is an addon that does the same on a tilemap.

    construct.net/en/make-games/addons/252/tilemap-flood-fill

    Tilemaps are essentially 2D arrays. So you can copy array values on a tilemap, flood fill it, then copy back to the array. Since this is for a jam, it could be a quick and easy solution.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I can't help you with the array, but there is an addon that does the same on a tilemap.

    https://www.construct.net/en/make-games/addons/252/tilemap-flood-fill

    Tilemaps are essentially 2D arrays. So you can copy array values on a tilemap, flood fill it, then copy back to the array. Since this is for a jam, it could be a quick and easy solution.

    I think I saw that addon before but never concidered that I could use it for my project; I'll try it out. Thanks for the tip!

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