How do i create a list of sprites that are all overlapping each-other?

im making a cell simulation game, and i coded the cells so that they group together. when they do this, though, cells on the inside cannot eat food to survive. i want to make it so that all cells in a group are added to a list, and all cells in that list get their food data increased. can anyone help me do this, because i have almost no clue how to.

here is the simulation: https://arcade.makecode.com/S45054-72685-31633-10145

by the way, the first number displayed is avg speed, and the second is avg lifespan.

1 Like

I think the way I would do this is that when a cell is attacked to another, and one of them has more food, the one with more gives some to the one with less. That way, big groups of cells need to eat more food to keep themselves alive.

Another way is by using the sprite data extension to give your cells a “clump ID number”, and then search the “array of all sprites of kind [cells]” for cells with matching clump IDs and give them all the same food. You could have a variable like “current highest ID” that goes up every time a new ID is needed, so the IDs never repeat, and then maybe if two clumps that already have IDs meet, they all take on the higher ID number.

I think I will use your second idea. thanks, but I still want to know if there is a way to create a list of all overlapping sprites - at this point I’m just curious how it would be done.

1 Like

To get a list you would have to check if that sprite was touching every other sprite and add the other sprites to a list. This is very annoying because there isn’t really a “is this sprite touching this other sprite?” block (unless I’m forgetting one). There’s definitely a function for this in JavaScript, because how else would that “When sprite touches othersprite” block work, but someone would have to make an extension for it to be a block.

there is a block for it, but the main problem is that there are some groups in which 1 sprite is not touching another, but another one is. for example, sprite A is touching sprite B but not sprite C. sprite B is touching both sprite A and C. sprite C is touching sprite B. the problem is adding all of those sprites to a list just from a collision between sprite A and B.