how to make a locker in scratch

How to Create a Locker in Scratch: A Step-by-Step Guide

By Steven Young
AD

Scratch is an engaging platform that enables users, especially children, to create and share animated projects with creative coding. One exciting feature of Scratch is the ability to create interactive block systems, including lockers. In this comprehensive guide, you'll learn how to create a locker in Scratch, step by step.

Creating a locker involves designing blocks that represent locker sections and using programming blocks to manipulate them. By the end of this tutorial, you'll have a functional locker in Scratch that stores and drops blocks when interacted with.

Planning Your Locker

Before diving into the Scratch interface, plan the design and functionality of your locker. Suppose you want a 3-section locker that stores blocks of different colors: Red, Green, and Blue. Each section will have a specific block color for easy identification.

AD
DIY - Cinnamoroll Mini Locker Organizer #shorts #sanrio
DIY - Cinnamoroll Mini Locker Organizer #shorts #sanrio
DIY mini locker #short #craft #craftideas #handmade #diy
DIY mini locker #short #craft #craftideas #handmade #diy
How to Make a DIY Locker from Cardboard
How to Make a DIY Locker from Cardboard

Consider the actions you want your locker to perform: store blocks in the locker, retrieve a specific block when requested, and drop all blocks if the locker's 'secret door' (hidden feature) is found.

Creating Locker Sections

Start by creating the visual components of your locker. Use the 'Backdrops' palette to pick a suitable background, then design your locker sections. You can use rectangles or any shape you like to represent your locker sections. In our case, create three rectangles in different colors: Red, Green, and Blue.

Thread Pattern Locker
Thread Pattern Locker
How to Make a Safe Locker with Smart Key
How to Make a Safe Locker with Smart Key
a purple mini locker sitting on top of a counter next to a vase filled with flowers
a purple mini locker sitting on top of a counter next to a vase filled with flowers

Position these rectangles neatly, one on top of the other, to represent the three sections of your locker. You can use the 'Data' blocks to store block colors for each section. For instance, set 'data-item (Locker1 v)' to 'Red', 'data-item (Locker2 v)' to 'Green', and 'data-item (Locker3 v)' to 'Blue'.

Strings and Messages

To make your locker interactive, use 'Strings & Messages' blocks to create custom messages. For instance, create strings like 'Store Red Block', 'Store Green Block', 'Store Blue Block', and so on. Similarly, create messages like 'Block Stored Successfully' and 'Locker Empty'.

AD

These strings and messages will help users interact with your locker and provide feedback on the actions performed.

a man is working on a wooden block with the words, come with me while i make a custom cut out for a mushroom lockers
a man is working on a wooden block with the words, come with me while i make a custom cut out for a mushroom lockers
How to Make a Bitmoji Locker for School
How to Make a Bitmoji Locker for School
캐비닛 만들기 🗄💜 | 무료도안 | DIY Locker
캐비닛 만들기 🗄💜 | 무료도안 | DIY Locker
Locker Room Poster Freebie!
Locker Room Poster Freebie!
✨ DIY Aesthetic Locker Makeover Red theme 🍓 | Handmade decor | Cozy Pinterest vibes
✨ DIY Aesthetic Locker Makeover Red theme 🍓 | Handmade decor | Cozy Pinterest vibes
a pink refrigerator sitting on top of a table next to a pile of books and papers
a pink refrigerator sitting on top of a table next to a pile of books and papers

Programming Locker Functionality

Now that you've created the visual and data components of your locker, it's time to make it functional. Using the 'Events' palette, click on 'When clicked' to start programming the actions that will occur when a user interacts with each locker section.

Start with the simplest action: storing a block in the locker. When a user clicks on a locker section (like the red one), the block selected should be stored in that section. To do this, use 'Repeat Indefinitely' block to continuously check for any block being dragged into the locker section.

AD

Storing Blocks in the Locker

Inside the 'Repeat Indefinitely' loop, use the 'Ask' block to check if any block is being dragged into the locker section. If a block is detected, use 'hide' block to hide it and show a 'Stored Successfully' message. Additionally, update the data value of that locker section to indicate the block color stored.

For example, when a red block is stored in the first locker section, update 'data-item (Locker1 v)' to 'Red'.

Retrieving Blocks from the Locker

To retrieve a block from the locker, use an 'When this sprite clicked' event block for each locker section. When a user clicks on a locker section, show a 'Please wait...' message and check if a block is stored in that section. If a block is stored, use 'show' block to display it and clear the data of that locker section.

AD

If no block is stored in that section, show an 'Empty' message.

Implementing the 'Secret Door'

Let's add the hidden 'secret door' feature. When a user clicks on a specific part of the stage (the secret door), use ' When this sprite clicked' event block to make all locker sections empty and show a 'Found the secret door' message.

You can hide the 'secret door' by making the area around it transparent or using a clever design.

Congratulations! Your interactive locker in Scratch is now complete. Try out your project, store and retrieve blocks, and find the secret door. Keep experimenting with different shapes, colors, and interactions to make your locker unique. Happy coding!

AD