Collect all Food before Progressing

mechanics space polish and systems

Add a Logic Step into our Overlap Listener

To add this patterns we need to add some logic the overlap listener which checks to see if the player is touching the end goal. Drag in an if then logic block and follow up with a 0 = 0 operator comparison block. From Advanced > Arrays drag a length of array list block into the first side of the comparison block. collect all food

Check the number of Food Items

Check the number of food items by replacing the list variable with a real list. In this case the list of food items. To do this drag in from Advanced > Arrays a block that says set sprite list to array of kind Player. Drag this into a blank area near our overlap listener as we only need on part of it.

collect all food

So Drag the blue block saying array of kind player inside the length of array block, and change Player to Food. Check with the screenshot below.

collect all food

Test your Changes and Next Steps

Test your game to check that your changes have the desired behaviour and that there are no side effects. For example, do you have to collect all food or can you progress without doing that?

This Game Pattern is one of many allowing you to make improvements to your platform game and to learn coding and wider computing concepts. Find more on the Game Pattern page.