So, I have started a project on the program "Scratch". It is a top-down Zelda style game, but I need enemies to spawn randomly around the stage. Is this possible? If not I may need to restart, so PLEASE PLEASE if this isn't possible, could you tell me the next best thing? Thanks!
Possible, but it cannot be entirely random. You have to decide the maximum number of enemies that can spawn, and set their positions. For example, they may all start from one position, or have different, defined positions from where they can spawn.
You may use different enemies, or just duplicate a certain enemy for this.
Then, at the note of "Broadcast X", like, say, "Broadcast Spawn Enermy", you can give a number to be set as the variable with the "Pick random X to Y" script and put in numbers.
Like: [Set Variable A to (Pick random X to Y)]
In this way, any of the enemies, which you should "Hide" by using the script when the Green Flag is clicked, have a chance to appear. Say you have 10 set enemies. During the broadcast, there is an extremely low chance for 10 enemies to appear at once. This can also, however, lead to a glitch that shall cause enemies to stop spawning, but that should not be a problem if you can program some sort of backup catalyst. For example, maybe the catalyst is broadcasted every 5 to 10 seconds seconds?
Like:
[Wait (Pick random 5 to 10) seconds]
[Broadcast (Enemy Spawn)]
To avoid the common glitch that comes with the "Forever" script, you can do this, if the monsters only spawn in a certain area. You can use a variable to determine the area.
Like:
[Forever]
[> If [(Stage) = Monster Zone)]
[Wait (Pick random [5] to [10]) seconds]
[Broadcast (Enemy Spawn)]
[>Else]
[Insert nothing here]
And:
[When I receive (Enemy Spawn)]
[Set (variable) to (Pick random [1] to [10]]
[>If (Variable = [1])
[Broadcast (Spawn 1 Enemy)
[>Else]
[>If (Variable = [2]]
[Broadcast (Spawn 2 Enemies)]
And so on...
I hope that helps. If you have any questions, feel free to ask!