In this video, you’ll program the object that the player is looking for to appear inonly one location. To start, choose what your sprite is lookingfor. Click the object sprite, then go to the “costumes” tab. There are a few differentchoices available. Choose one of these items, or add a different object from the costumelibrary. What might your character need to find?
Once you’ve chosen an object, go back to the “scripts” tab, click “looks,”and drag out “show” and “hide” blocks. The “show” block should run when the backdropchanges. Click events, and drag out a “When backdropswitches” block. Click the dropdown, and select the name ofthe location where your object will appear. This example uses the cave, but you will chooseyour own location for the object in your game. Then, drag another “when backdrop switches”block onto the “hide” block, and select “town.”
Click the flag to try it out. Move the sprite to the location you just selected, and great,the sprite appears! Next, program a winning condition that willhappen *if* the player sprite touches the object.
Place a forever loop and an “if” statement under the “show” block.
Add a “touching” block from sensing, and select “character” from the dropdown.
Create a winning celebration. You might play a sound, or use a “say” block to say,“Yay, you win!” Click the flag to try it out. Move the spriteuntil it finds the object, and… great! Now, it’s your turn:Select the object sprite and a costume from the costumes tab.
Show the object in one location using “when backdrop switches” and “show” blocks.
Hide the object at the start of the program using “when backdrop switches” and “hide”blocks. Program a winning condition using “touching,”“forever,” and “if” blocks.
In the next video, you’ll add more storytelling elements to make your game more exciting.