Okay so basically I want a simple enemy wave system that spawns enemies in a list that I can manually change.
I have pretty much all of the code set up, however, I don’t know how to use an array to help me; I want the code to be able to read one item in the array, change a variable based on the item, then go to the next item down the list.
For example: An enemy wave array would look like this:
array = [1,2,3]
I want the code to read the first item, and when it sees that it’s “1”, it would change the variable to whatever I have “1’” as. Then, it would go down an item and then read that one, see it as “2”, and change the variable. Same thing for three. Once all of the items are read, the enemies stop spawning.
I have no idea how I could achieve this with an array, since I’m still a mega-noob. Any help would be immensely appreciated.
Why would you enter 1, 2, 3 into the array only to replace them with what you really want there? It is an extra step for no reason at all. It just makes things more difficult for you.
The 1,2,3 is for easy editing. The idea is that it would read 1, and set the spawner to spawn a specific enemy for that wave, the same for the other numbers. The numbers allow me to quickly edit the enemies that will spawn.
I need the spawner to have time to read which enemy it needs to spawn, that variable is taken from whatever singular element is being read from the array at that time. I want to know how I can make it stop at that specific element, give the spawner time to spawn the enemy, then move next to another element, which it will stop to again.
Those two things are not in the same category. Array stores data. A sequencer is a program that can be driven by that data to trigger events distributed in time. So array can represent a sequence, and that program that reads it is then a sequencer. It’s like playing music from a music sheet. The notes of your song can be stored in an array but something/somebody needs to read them and play them in correct timing.
The thing that you still need to explain is what determines those delays.
I suggest you describe exactly how the final result should look from the player perspective.
Alright so the idea is that the player walks into a room, the doors lock behind them, and they are treated to a small cutscene (which I’ll figure out later). Once the cutscene is over, an enemy will spawn, which the player defeats.
After a short delay, a different enemy spawns, which they defeat as well. This repeats, with the enemies being spawned in patterns. Eventually once they defeat a specified amount of enemies, the doors unlock and enemies stop spawning
Make a duplicate of the array. Whenever you need a new enemy to spawn, pop the first element off the array using Array::pop_front() and spawn an enemy that matches the popped value. When the array is empty, the sequence is done.
UPDATE: It works like a charm. I had the duplicate of the wave_list (1,2,1,2,1) be the one being used with pop_front(), and it works perfectly. Thank you very much for the help.