How to spawn wave of enemies and the boss


#1

Hi!
I want to create a game with many levels, each level have some waves of enemies and one boss in the last wave.
What should i use to make level, wave of enemies and one boss at the last? From the document i am plaining to use :

  • Collection proxy to create level
  • Collection factory to create enemy inside wave
  • Collection factory to create one boss - Is this best way if we have only one boss?
    Thank so much, sorry for my bad of english, i am learning Defold so i want to understand best way to architect the game.

#2

Sounds like a good plan. Perhaps there’s no need to spawn the boss using a collection factory, unless there is some condition such as “Kill all enemies before boss spawns” in which case it makes sense to use a factory.

What kinds of game are you doing? I’m mostly thinking of how to know when to spawn enemy waves? Is it a horizontal or vertical shoot’em up where distance traveled could be the factor that triggers waves? Or maybe you could use enemy wave trigger objects that you place on your level and trigger when the player gets near (using a large trigger collision object that follows the player).


#3

Yes it will be good to know what type of game you’re working upon. For eg: as @britzl mentioned, games like shmup spawn waves based on distance travelled, while some other like plants vs Zombies or tower defence do so based on time elapsed, and some survival games depend on number of enemies killed and so on So, it would be good to know what type of game you are working with.
BTW here is a small example that @pkeod showed me a while ago


#4

Hi! Thank so much for the quick help!
Yes, my game is a vertical shoot’em up (portrait mode), which will be 50 levels or more. Here is my plan:

  • Each level will have 5 to 8 waves and the last wave maybe have a boss or not.
  • Each wave will have the same enemy type, and condition for the next wave is a current wave is empty of enemies (player kills all enemies in that wave) or time is reach some fixed number (in case of wave exist too long, the player do nothing and so the bad guys too)
  • The boss wave will have one or boss and mini-boss and condition is the same as wave (boss appeared when the last wave end)
  • The level data should be read from LUA table or some JSON files

I still wonder if it needs to spawn only one boss using collection factory? Is collection factory is the way to create a collection and even if we need only one instance?

Thanks for the support and it is getting clearer now!


#5

OK then.

The game can be structured in two ways :

  1. Create a base collection called controller, which handles every basic things like loading and saving data, loading levels etc.
  2. When the game starts, use the controller to load the menu, which handles things like level selection, shop etc.
  3. Create 50 collections each pertaining to a level and load it by passing messages to the controller from main. Use a collection proxy for this.
    While this method is very simple to choose. I won’t choose it if I were you.
    The simple reason is that all the 50 levels you create will have no difference from each other than in terms of backgrounds, waves and enemies and bosses.
    So the alternate way can be to create a single collection called level. Then create a lua module which contains data of all 50 levels and based in that data assign properties to your level.

That was just the first part :stuck_out_tongue:

Use a lua table to create a time line which will then decide, based on distance travelled or time taken whether to spawn the next wave , much like in the example. Then use another set of lua tables to store the formation in which enemy will appear. Then cut and paste them in the level table I mentioned before and use a factory(if your gameobjects) are not that big to spawn an enemy or a collection factory ( if they are really that complex) .

Finally to achieve this, you can again use two ways. Use a collection factory to spawn a boss in the last wave, or just add the boss manually to the level collection, and disable it in the beginning and then enable him when it’s the perfect time to wreck havoc.
(I am away from my computer for a while, else I could have given u a small example to explain what I mean above :cry:)


#6

Thank for detail explain, it really help me a lot!
So I will use each collection for each level, that fine!
Now for the detail of level, for example, if in Level 1 I have enemy type 1 and enemy type2 and one boss type x, they make using the collection (they quite complicated so I think they are collection, not game object). Can I dynamic add collection factory using script or I must add them in the editor as a place holder to spawn collection later?
Thanks!


#7

No. You need to manually place them in the editor, as a placeholder to spawn collections later. Dynamic creation of collection factories is not allowed in Defold.
You can then request the collection factory to spawn a collection at runtime.


#8

Hi @kashyapaayush32 and @britzl
Thank so much for your help!