Lesson Overview
In the Previous Step, we programmed it so that when the Player bumps into the Walls of our Maze, they are sent back to the Start.
In this Step, we will be programming a “Finish Line” into our Maze. Since the Goal of our Maze is to retrieve the Treasure, we will be making this our Win Condition.
Continue from the Previous Lesson, or use the template linked below. Hover Mouse below to reveal template link
Step 1: Sprite Collisions
Select the Treasure Sprite. Begin by grabbing the “When Green Flag is Clicked” from the Events section. We will also need a Forever loop from the Control section.
Inside of the Forever loop, we will need an “If-Then”. Inside of the “If-Then”, place the “Touching Mouse-pointer” Block from Sensing. This block of code detects for when the Treasure Sprite comes into contact with another Sprite or Entity. For our game, we will want to detect when the Player comes into contact with the Treasure.
Click on the White Arrow to change “Mouse-pointer” to Sprite1.
Because we placed this conditional statement inside of a Forever loop, it will continue checking the entire time that the game is being played.
When the Player comes into contact with the Treasure, we will want it to broadcast the “GameWin” Message. This block can be found in the Events section.
Broadcasting allows us to send out a signal for another Sprite to receive. That Sprite can be programmed in turn to take an action upon receiving the Broadcasted message.
For our Game, we will want the Treasure to broadcast the “GameWin” message when it is touching the player.