How can i make spreading "Slime"

Hi
I want to make green spreading slime with from cubes similar to this: (on bottom)

Any hints how to make it with C#?
Thanks :slight_smile:

There’s a couple points to note here but it looks pretty easy to implement.

Your primary control concern is likely to be “how fast does this spread?” and that’s pretty easy to encapsulate in a timer that expires every X seconds.

For actually doing the effect, I don’t know their algorithm (obviously), but I will speculate what they are doing and write you some pseudocode steps:

  • periodically do the following en-slime-ment:
  • randomly search for existing slime tile (could scan the map, or could keep track of all slime tiles in a list)
  • check 4 directions to see if it has a slime-able tile immediately next to it
  • spawn a new slime in that direction
  • reset the timer you used to decide the “periodically” value

As for resetting the timer you can make it a random value too, so the slime doesn’t spread with regularity.

The randomness will tend to cause it to get into random different shapes each run.

2 Likes