How do I make a mechanic where if you kill all things on screen, it takes you to the next level?

I’m making a game like duck hunt-ish and I need to know this please.

It is pretty simple.

Make a separate object off-screen

Off Screen Object
Mailbox (point) - number (1) - filter = (whatever the number of enemies there are in that level) - next level

Message (point) to Off Screen Object

If there are multiple levels like this, you have to keep making separate Off Screen Objects, and keep doing this chain of code.
Hope this helps!

Thanks this helps a lot. I’ve been using flowlab for a while, but this type of game is new to me. I usually make platformers. Have a nice day.

Glad to help! :slight_smile:

I’m actually not getting it to work, could I see an example? I know I’m doing something wrong, I just don’t know what.

Another Easy example is that you should add a health system of some sort using numbers and filters, then when the health reaches zero it will send a mailbox to you, add a filter saying the number of enemies there are so when all of the enemies are defeated you can progress to the next level. I don’t know if it can help or if I explained it correctly, but this has helped me on some of my games.

Can you screenshot your code? I cannot do coding at this time, so I can only best help you by seeing what you did wrong.

@ManiacPumpkin hmm. Never thought of that example.

It’s like your example, but more simplified. At least I found this out when testing out different designs on flow lab.

Another way to do this that is slightly more complicated but much more versatile is to have all the enemies on screen send a message to the player or an off screen object telling it to NOT go to the next level. You can pretty simply do this with a couple gates and filters. This way you can use the same code for each level no matter how many enemies there are. Also if you want to exponentially spawn more enemies this lets you. Idk just an idea.

Thanks all of you, this has all been great~!

screen clipping

Here’s a screenshot, I’m still not getting it, but i’m closer.

Ah, I see the problemas.

first, attach the mailbox to in, not set.

Next, get another number block, and put it at 0

Hook the 1 number to the 0 number through add. Think that should do it.

@ShadowAxeKid that wouldn’t work because of how the filter is set, try this instead.

Mailbox>in-number–1>±number-(however many enemies you want)>in-filter-0>next level

@“my_name (<_>)” ah, yes. A mistake from me. XD. That works too.

This helps, but It’s still not working. I think I’m doing something wrong on the enemies.

screen shot

But, I think I’m closer. You guys have been a great help.

Here is what I did, just import it into your game

Also how do you make it so it doesn’t show the whole thing?

{“data”:{“behavior”:{“v”:“2”,“nodes”:[{“inputCount”:0,“outputCount”:1,“name”:“Mailbox”,“behaviorType”:“logic.components.Mailbox”,“x”:270,“y”:192,“group”:"",“id”:“276b05651e305d4b”,“msg”:“death”},{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:450,“y”:192,“group”:"",“id”:“276b4e3d1a027648”,“startVal”:-1,“tag”:""},{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:630,“y”:192,“group”:"",“id”:“277042a3c2208146”,“startVal”:5,“tag”:""},{“gateVal”:0,“mode”:“equal to”,“inputCount”:2,“outputCount”:2,“name”:“Filter”,“behaviorType”:“logic.logic.Filter”,“x”:810,“y”:192,“group”:"",“id”:“2773f34cfd7bad4f”},{“inputCount”:1,“outputCount”:1,“name”:“NextLevel”,“behaviorType”:“logic.gameflow.NextLevel”,“x”:990,“y”:192,“group”:"",“id”:“27744dce8b45e940”,“levelName”:null}],“links”:[{“input_id”:“276b4e3d1a027648i1”,“output_id”:“276b05651e305d4bo0”},{“input_id”:“277042a3c2208146i2”,“output_id”:“276b4e3d1a027648o0”},{“input_id”:“277042a3c2208146i2”,“output_id”:“276b4e3d1a027648o0”},{“input_id”:“2773f34cfd7bad4fi0”,“output_id”:“277042a3c2208146o0”},{“input_id”:“2773f34cfd7bad4fi0”,“output_id”:“277042a3c2208146o0”},{“input_id”:“27744dce8b45e940i0”,“output_id”:“2773f34cfd7bad4fo0”},{“input_id”:“27744dce8b45e940i0”,“output_id”:“2773f34cfd7bad4fo0”}]}}}

@“my_name (<_>)” Click the thing on the bottom left corner of the screen. (Idk what computer you have, so I can’t be specific.) Search the “snipping tool”

It still won’t work, I imported the code. I am really lost at this point. Here’s all my code if it helps. And, sorry if I don’t get back for a while, I’m going to be away for the weekend.

screen screen

screen screen screen

Have an enemy’s death add to a number, for example every death adds 1 to a total put that in a filter anything equal to 10 plugs that into next level, kill all 10 enemies per se and done.