Theory
🐱 12. What is the Password?
Have you ever wanted to visit a castle? This one is closely guarded by a very strict knight. He won’t let anyone near the castle gate unless they can tell him the secret password. But how will the knight know if you get the password right? We’re going to use a condition to help him out.
Step1
Bring in Knight from your sprite library. Then load Castle1 and Castle2 from your backdrop’s library.
Step2
🏰 Start knight’s script with “when flag clicked” event; Switch backdrop to Castle2 & show knight 🛡️🔍
👮♂️ Position knight in path’s Centre; Prompt password with “ask ‘Halt! What is the password?'” block 🛡️🗝️
Step3
🔒 Introduce condition with “If () then () else ()” control block
🕵️♂️ 🔑 Use “answer sensing” block in “() = (__)” operator for password check; Type in “pumpkins” as the password 🎃🔒
Step4
🔓 Connect condition to script: Place actions for correct password inside If-Then section 🤖✔️
🏰 Knight congratulates with “That is correct!” say block, switches to Castle1 backdrop, & disappears with hide block 🎉🏰
Step5: Code Completed
🔒 In the “else” section, insert a say block with “Nope. Click the flag to try again.” message
🛡️❌ 🏰 Knight remains loyal: Only correct password unlocks passage to Castle1 backdrop; incorrect triggers message 🤖🔑
Step6
🔄 YOUR TURN! Challenge yourself:
- 🛡️ Extend condition: If correct, knight guides; if wrong, knight reacts angrily.
- 🐉 Introduce dragon sprite: Place beside knight, make it breathe fire upon incorrect password entry. 🔥🐉