Lesson 4: Introduction to Scratch
Learning Objectives
The outcome’s Scratch aims to achieve:
- Develop computational thinking skills: Scratch provides learners with an opportunity to think logically and systematically, breaking down complex problems into smaller parts and finding creative solutions.
- Learn programming fundamentals: Scratch introduces students to programming concepts such as sequencing, loops, conditional statements, and variables in a fun and engaging way.
- Foster creativity and expression: Scratch provides a platform for students to express their creativity and imagination, creating games, stories, and animations that reflect their unique personalities and interests.
- Develop collaboration and communication skills: Scratch encourages students to work together, share their projects, and give and receive feedback, developing their collaboration and communication skills.
- Build digital literacy: Scratch helps students develop digital literacy skills such as problem-solving, critical thinking, and responsible use of technology.
Becoming Familiar with the Scratch User Interface
What is the Scratch interface?
This is the visual platform or window, where learners can create their own stories, games and animations.
Think of your Scratch window as a stage for a play. On the stage, you have a main actor called the "Sprite" who performs actions. The Scratch interface is like the stage where the play takes place.
The Sprite can move, speak, and perform actions. The Scratch blocks are like lines or instructions given to the Sprite. By combining these blocks, you create a sequence of actions for the Sprite to perform, just like a script for an actor.
The stage also has different backdrops, which are like different scenes in the play. You can switch between backdrops to change the setting or environment for the Sprite's actions.
In addition to the Sprite, you can add other actors or characters to the stage, called "Costumes" in Scratch. These actors can have their own actions and behaviours, and you can create interactions between them and the main Sprite.
Overall, Scratch provides a stage where you can control the actions of the Sprite, switch between different backdrops, and add other actors to create your own interactive play. It's like directing a play with actors on a stage, but in a fun and creative digital environment.
So, lets check out the Scratch interface:
https://scratch.mit.edu/Scratch User Interface:
There are several sections in the Scratch interface, including:
Block Palette:
This is where users can find all the programming blocks available in Scratch. The blocks are organized into categories such as motion, events, control, and sensing. These blocks are graphical representations of programming commands and are used to create code by snapping them together like puzzle pieces.
Coding Area:
This is where users can drag and drop blocks to create code for their project. Users can connect blocks together to create a sequence of instructions for the sprites to follow. Each interactive element like a stage or a Sprite has a unique coding area. Change the coding area by clicking from one Sprite to another.
Stage:
This area provides a visual and interactive environment for users to see the results of their programming code and create engaging animations and games. The stage can be customized with differing backgrounds and sprites. Each pixel on the stage has an x and y coordinate.
By default, the Scratch stage size is 480 pixels wide and 360 pixels tall, with the center point at (0, 0). This means that the x-axis ranges from -240 to 240, and the y-axis ranges from -180 to 180.
If you want to move a sprite across the x and y axis in Scratch, you can use the "go to x: y:" block or the "change x by: y" and "change y by: y" blocks.
Sprite List:
This area displays all the sprites (i.e., characters or objects) used in the project. Users can select a sprite to modify its properties or add new sprites to the project. A sprite can be any image or icon and can be selected from the Scratch library or uploaded from your computer. Each sprite has its own set of scripts, which are made up of blocks that can be snapped together to create different behaviours and interactions. Sprites can move, change costumes, play sounds, and more, all based on the blocks you use to program them.
Costumes:
This area displays all the different costumes (i.e., appearances) for a selected sprite. Users can add, delete, or edit costumes to customize the sprite's appearance.
Sounds:
This area displays all the different sounds used in the project. Users can add new sounds or record their own sounds to use in their project.
Steps to set up a Scratch Account:
- Go to the Scratch website https://scratch.mit.edu/
- Click on the "Join Scratch" button in the top-right corner of the page.
- Fill out the registration form with your username, password, birthdate, and country.
- Check your email for a message from Scratch with a verification link. Click on the link to verify your account.
- Once your account is verified, you can log in to Scratch using your username and password.
Benefits of Creating a Scratch Account
- Save and share projects: With a Scratch account, users can save their projects to the Scratch website, allowing them to easily access and continue working on their projects from any computer with an internet connection. Users can also share their projects with others, view other Scratch projects, and collaborate with other users on projects.
- Access to community features: Scratch has a vibrant online community where users can share their projects, receive feedback, and collaborate with other users. By creating an account, users can participate in the community and take advantage of features such as commenting, remixing, and following other users.
- Personalization: With a Scratch account, users can personalize their Scratch profile by uploading a profile picture and adding a description. This can help users connect with other users who have similar interests and can also help users highlight their skills and projects to potential collaborators or employers.
- Mailing List: Subscribe to receive regular updates on new features and project showcases. Stay informed about community events such as scratch conferences, educational resources and have opportunities for collaboration with other Scratch users. It's a convenient way to stay connected, get inspired, and enhance your Scratch experience.
Overall, creating an account with Scratch offers users access to additional features and resources that can enhance their experience with the platform and support their learning and creative projects
Demonstration Program: Catch the Fruit
This is an example of a simple and fun Scratch program that covers conditional logic, loops, and variables:
ObjectiveThe aim of the game is to move the bowl right or left, using keyboard arrow keys, to catch a falling apple and associate differing sounds for either a successful catch or a miss.
Steps:- Open Scratch and create a new project
- Delete the cat sprite by pressing on the bin icon shown in the image
- Add a new sprite of a bowl. Click the add sprite button and type bowl in the top left search bar then click on the bowl
- Add a new sprite of a fruit. Click the add sprite button again and this time search for an Apple and click on the Apple.
- Click on the bowl sprite. You should see the bowl in the top right corner of the code area. Add the three code snippets shown in the image.
- First code snippet positions the bowl to the center once the green flag is pressed
- Second code snippet moves the bowl 10 pixels right when the right arrow is pressed
- The third code snippet moves the bowl 10 pixels left when the left arrow is pressed
- Click the Apple Sprite and build up the following code snippet
- Test the program and see if you can catch all the falling fruit!
This is how the code snippets for the bowl work:
Brainstorm!
Can you think of ways to enhance the game?
Examples:
- Add more fruit types
- Creating a scoring system
- Add power-ups – so add a “sprite” that when caught you can increase your score.
These are purely suggestions if you have better ideas go with them.
Scratch Ideas
Scratch - Ideas (mit.edu) brings the user to the Ideas page on the Scratch website and it is a great entry point for both students and teachers as gives multiple tutorials varying from beginners to more seasoned scratchers. It offers both the code and an educator’s guide to further facilitate each tutorial.
Exercise
Instead of catching fruit in a bowl let us use the same idea to create a game where the spaceship breaks the asteroids to avoid getting destroyed by impact in scratch. It is like catching the apple in the bowl, just in reverse, dodging the asteroids.
This exercise is designed to reinforce the concepts and implementation from the demo, a starship, lasers, and asteroids are used here, but you are not limited to these. It will work equally well with other examples such as a cat throwing flowers at descending fluffy clouds. The objective is to showcase what you have learned, but the story is yours.
StepsHere are the steps to create a game where a spaceship breaks asteroids to avoid getting destroyed by their impact in Scratch:
- Open the Scratch programming environment and create a new project.
- Choose a spaceship sprite and an asteroid sprite from the Scratch library or upload your own.
- Set up the game background, you can use a space or galaxy image or create a simple black background.
- Add the spaceship sprite to the centre of the screen.
- Create code for the spaceship movement, allow it to move horizontally and vertically using arrow keys or mouse movement.
- Code for spaceship lasers, use the "when space key pressed" block to make the spaceship fire lasers.
- Create code for asteroid generation and movement, randomly generate the asteroids that move downwards on the screen.
- Code for detecting collision, use the "if touching" block to detect when the spaceship's laser hits the asteroid. If a hit is detected, destroy the asteroid and add score points.
- Code for game over, use the "if touching" block to detect when the asteroid hits the spaceship. If a hit is detected, end the game, and display a game over message.
- Add sound effects and music to enhance the gameplay experience.
- Test the game, make sure the spaceship and asteroid movements and collision detection are working correctly.