Lineup. Introduction. What you will need. Import your costumes. What you will make. What you will learn. Hardware. Software

Similar documents
Make a game in which you play the notes of a song as they scroll down the stage.

Add in a new balloon sprite, and a suitable stage backdrop.

ICS 61 Game Systems and Design Introduction to Scratch

Teaching Kids to Program. Lesson Plan: Catch the Ball

Scratch. Creative Computing

AN INTRODUCTION TO SCRATCH (2) PROGRAMMING

In this lesson you are going to create a drawing program similar to Windows Paint. 1. Start with a new project and remove the default cat sprite.

Introduction to Scratch Programming v1.4 (Second Ed) Lesson 6 Calculator

Meet the Cast. The Cosmic Defenders: Gobo, Fabu, and Pele The Cosmic Defenders are transdimensional

Mailman Max. The postcode is a great way to work out the next sorting office a letter should go to, so you ll use that.

Computer Science Concepts in Scratch

Computer Science Concepts in Scratch

Lost in Space. Introduction. Step 1: Animating a spaceship. Activity Checklist. You are going to learn how to program your own animation!

M O T I O N A N D D R A W I N G

Lost in Space. Introduction. Scratch. You are going to learn how to program your own animation! Activity Checklist.

Teacher Cheat Sheet - Game Coding Challenges

All Blocks of Scratch

ONE HOUR ANIMATION. Will you be a Scratcher upon completion of this session? Definitely. Learn how to write a basic script to animate a sprite.

micro:bit game controller with Scratch

Lesson 3 Creating and Using Graphics

CPS111 Victory Thru Scratch Lab

S3 Scratch Programming

How to Use Internet Explorer 9

The Environment. Scratch Programming. The Environment. The Environment. The Environment. The Environment. Lesson 1: Introduction THE STAGE

SCRATCH MODULE 3: NUMBER CONVERSIONS

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

You can delete the default blank background by clicking on its Delete button.

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

Using Microsoft Word. Text Editing

VISUAL PROGRAMMING BY SCRATCH

Scratch Programming for Primary School Teachers Quiz Game

Using Flash Animation Basics

Crossley Fields - Computing Vocabulary

Digital Technologies in focus:

An Animated Scene. Pick a color for the street. Then use the Paint can to fill the lower part of the page with grass.

Duplicate and customize an existing kahoot to fit your needs. Launch and host a kahoot game in your class

We created a few different effects and animations using this technique as applied to clones.

Using Devices with Microsoft HealthVault

Making a maze with Scratch

Using Microsoft Excel

Working with Windows Movie Maker

Scratch Lesson 2: Movies Made From Scratch Lesson Framework

EchoSub v1.2 EchoStyle

The Beauty and Joy of Computing 1 Lab Exercise 1: Introduction to Scratch/BYOB - Animations and Communication

Shape and Line Tools. tip: Some drawing techniques are so much easier if you use a pressuresensitive

Instructions for Using the Databases

Course contents. Overview: Goodbye, calculator. Lesson 1: Get started. Lesson 2: Use cell references. Lesson 3: Simplify formulas by using functions

Android Programming Family Fun Day using AppInventor

Animate a Name Cards

SNOWFLAKES PHOTO BORDER - PHOTOSHOP CS6 / CC

GoLive will first ask you if your new site will be for one individual or a work group; select for a Single User, and click Next.

The isit. Admin Overview. Use the left and right arrows to go through the instructions.

With the Photo-face project learners can incorporate digital media digital photos, and then transform these images in creative and surprising ways.

A Quick-Reference Guide. To access reddot:

Part 6 - Constructing Railroad Bridges

In this lesson you will learn: How to capture the input from the user. How to write programs using variables and lists. Athletics Swimming Gymnastics

Help For TorontoMLS. Report Designer

Keep Track of Your Passwords Easily

Tabbing Between Fields and Control Elements

GAME:IT Pinball. Objectives: Review skills from Introduction Introduce gravity and friction Introduce GML coding into programming

SAMLab Tip Sheet #4 Creating a Histogram

What is OneNote? The first time you start OneNote, it asks you to sign in. Sign in with your personal Microsoft account.

seminar learning system Seminar Author and Learning System are products of Information Transfer LLP.

MindTap Math Foundations Instructor s Guide to Communication Tools

Let s Make a Front Panel using FrontCAD

Remodeling Your Office A New Look for the SAS Add-In for Microsoft Office

Introduction to Windows 10 Part 1

How to fill out forms, forms, & add your own pictures / notes to forms (Mobile 2.0)

Decisions, Decisions. Testing, testing C H A P T E R 7

Copyright 2018 MakeUseOf. All Rights Reserved.

The Menger Sponge in Google SketchUp

On the Web sun.com/aboutsun/comm_invest STAROFFICE 8 DRAW

Lastly, in case you don t already know this, and don t have Excel on your computers, you can get it for free through IT s website under software.

Printing Envelopes in Microsoft Word

Depending on the computer you find yourself in front of, here s what you ll need to do to open SPSS.

Get Started in 10 Simple Steps

Studuino Programming Environment Manual

Programming Lab 1 (JS Hwk 3) Due Thursday, April 28

How to Use Facebook Live From Your Desktop Without Costly Software

Creating a Histogram Creating a Histogram

Scorebook Navigator. Stage 1 Independent Review User Manual Version

Depending on the computer you find yourself in front of, here s what you ll need to do to open SPSS.

Top 10 Productivity Tips in Fusion 360

Creating Buttons and Pop-up Menus

SCRATCH. Introduction to creative computing with Scratch 2.0

TTS Scratch Controller. Teacher Guide. 1 TTS Scratch Controller - Teacher Guide. Product Code: EL00530

Bb Collaborate. Virtual Classroom and Web Conferencing

Review of Computer Science and Scratch Concepts

Step 1: Adding Darwin to your computer

Audio is in normal text below. Timestamps are in bold to assist in finding specific topics.

CHAPTER 3. Entering Text and Moving Around

Designing Your Teacher Page. Medora Community School Corporation

Light Speed with Excel

VERSION GROUPWISE WEBACCESS USER'S GUIDE

Taskbar: Working with Several Windows at Once

Customizing DAZ Studio

Welcome to Introduction to Microsoft Excel 2010

Part 1: Basics. Page Sorter:

PowerPoint 2003 for Windows Version Technology Workshop: Basic PowerPoint Animation for Music Presentations

Transcription:

Raspberry Pi Projects Lineup Introduction In this project you will be making a game using Scratch 2.0. The game will involve nding a stamped sprite on the stage, hidden amongst a huge group of other stamps. What you will make Hit the green ag and, once the curtain has been raised, try and nd the clone before your time runs out. What you will learn This project covers elements from the following strands of the Raspberry Pi Digital Making Curriculum (http://rpf.io/curriculum): Apply basic programming constructs to solve a problem (https://www.raspberrypi.org/curriculum/programming/builder) What you will need Hardware An internet-connected computer Software Scratch 2.0 (online or o ine) Import your costumes Use the default cat sprite, and start by adding some more costumes. For this game you will need a lot of costumes! You ll want to import at least 40 from the Scratch library. It s best to select costumes from the People section, but the choice is yours. Adding new costumes in Scratch With your sprite selected, click on the Costumes tab You can choose one for the four options from the tab. From left to right they are: Choose costume from library Paint new costume Upload costume from le New costume from camera To import multiple costumes, you can hold down Shift while you are selecting them. Click on OK when you are nished. If you wish to delete the imported costume, select it and click on the small cross in the top right hand corner. Once you have your costumes, you can delete the default cat costumes if you like. https://projects.raspberrypi.org/en/projects/lineup/print 1/14

Making a grid You are going to produce a grid of stamped costumes, just like this one: To do this you will need to know the x and y coordinates of where each stamp is going to be placed. Have a look at the section below if you need a reminder about Scratch coordinates. Scratch coordinates Scratch coordinates In Scratch, the coordinates x:0, y:0 mark the central position on the Stage. A position like x:-200, y:-100 is towards the bottom left on the Stage, and a position like x:200, y:100 is near the top right. You can see this for yourself by adding the xy-grid backdrop to your project. https://projects.raspberrypi.org/en/projects/lineup/print 2/14

To nd out coordinates of a speci c position, move your mouse pointer to it and check the readings below the bottom right corner of the Stage. To begin with you ll need to create a new block called generate positions for your sprite. The block will need to have two number input parameters. Call the two parameters rows and. The values of these parameters will de ne how many rows and your grid will have. generate positions rows Making a block Click the Scripts tab, then on More Blocks, and then click Make a Block. Give your new block a name and then click OK. You will see a new block. Attach code to this block. You can then use your new block just like any normal block. https://projects.raspberrypi.org/en/projects/lineup/print 3/14

The code attached to your new block is run whenever the block is used. Next you will need to create two lists. One will be called x_positions, and the other will be called y_positions. Make a list Make a list Click on Data in the Scripts tab, then click on Make a List. Type in the name of your list. You can choose whether you would like your list to be available to all sprites, or to only a speci c sprite. Press OK. Once you have created the list, it will be displayed on the stage, or you can untick the list in the Scripts tab to hide it. Click the + at the bottom of the list to add items, and click the cross next to an item to delete it. https://projects.raspberrypi.org/en/projects/lineup/print 4/14

New blocks will appear and allow you to use your new list in your project. Underneath your generate positions block, add blocks to delete all the items from both lists. generate positions rows Next you will need to create two new variables. Call these x_pos and y_pos. Add a variable in Scratch Click on Data in the Scripts tab, then click on Make a Variable. Type in the name of your variable. You can choose whether you would like your variable to be available to all sprites, or to only this sprite. Press OK. https://projects.raspberrypi.org/en/projects/lineup/print 5/14

Once you have created the variable, it will be displayed on the Stage, or you can untick the variable in the Scripts tab to hide it. New blocks will appear and allow you to change the value of the variable. Your two lists are going to hold all the x and y coordinates for the characters on the stage. If you look at the two lists side by side, as shown in the table below, you will see that the rst index will correspond to the bottom left-hand corner of the stage. The next one will be a little bit to the right, and so on. index y_positions x_positions 1-150 -200 2-150 -155 3-150 -111 4-150 -66 5-150 -22 6-150 22 7-150 66 8-150 111 9-150 155 10-150 200 The table shows the coordinates of the rst row of images. They could be added to the lists manually, but that would take a little too much time. It s easier to do it with a loop. Start by setting the y_pos and x_pos variables to -150 and -200. This will be the location of the rst image. generate positions rows set y_pos to -150 set x_pos to -200 Now you need a loop to add the rst ten coordinates to the lists. So how many times should the loop? In this case it is ten - one time for each column in the grid. As you ve set up the block to take as a parameter, you can use this value. generate positions rows set y_pos to -150 set x_pos to -200 Within the loop, you ll need to add the values of x_pos and y_pos into the lists. Then you ll need to increase the value of x_pos by a little. The rst value you added is -200 and the next is approximately -155, up until you reach 200. So how can you calculate these increments? Well, as you want a total of ten values in the list, and the rst is already set to 200, you need an additional nine values. This is the value of minus one, so - 1. You want to go up to 200, so you ll need to add an additional 400 to x_pos. This means you want to add 400 / ( - 1) each time the loop comes around. Here s some code to get you started, and you can use the hints below if you need more help. https://projects.raspberrypi.org/en/projects/lineup/print 6/14

generate positions rows set y_pos to -150 set x_pos to -200 add to x_positions add to y_positions change x_pos by / - I need a hint Lastly you can add in 400 to the calculation, so it calculates the increase in x_pos each time. generate positions rows set y_pos to -150 add x_pos to x_positions add y_pos to y_positions change x_pos by 400 / - 1 Testing the script To test the script you ll need to call the block you have made. You also need to provide it with the number of you want in your grid. when clicked generate positions 1 10 Now click on the green ag to run your code. You should see your two lists ll with values. If your results don t look like this, then go back to the previous step and have a look at the hints again. Stamping a row So far you have ten values in the two lists. Let s stamp some costumes at the stage positions given in the list. Create a new block and call it stamp sprites. It needs two parameters as well, both of which should be number inputs and named row and just like the last ones. stamp sprites rows Create a new variable called index. You can use this to track which position in the list you are reading. Set it to 1. https://projects.raspberrypi.org/en/projects/lineup/print 7/14

stamp sprites rows set index to 1 Now you re going to stamp a sprite for each set of coordinates in the list. This will require a loop that will once for each column. stamp sprites rows set index to 1 Within the loop, move your sprite to the rst position in the list, stamp it, then increase the index by 1. stamp sprites rows set index to 1 go to x: item index of x_positions y: item index of y_positions stamp change index by 1 Next you need to call this block as well. You should also add a clear block to you starting script so that it clears the stage each time. when clicked clear generate positions 1 10 stamp sprite 1 10 When you click the green ag, you should see something like this: Changing the costumes Let s change the stamp each time and make it a more appropriate size. https://projects.raspberrypi.org/en/projects/lineup/print 8/14

stamp sprites rows set size to 40 % set index to 1 go to x: item index of x_positions y: item index of y_positions stamp next costume change index by 1 When you run the script, you should see something like this: At the moment, your program cycles through all the costumes in order. This isn t a problem, so long as you place the sprite in a random location each time. To do this, you ll need to follow the following algorithm: Set index to a random number between 1 and the length of a list Move the sprite as you did before Delete the index position from the y_positions list Delete the index position from the x_positions list Have a go at doing this part yourself, and take a look at the hints if you need some help. I need a hint Here is your completed script showing how to delete the items from the list: stamp sprites rows set size to 40 % set index to pick random 1 to length of x_positions go to x: item index of x_positions y: item index of y_positions delete index of x_positions delete index of y_positions stamp next costume Adding rows Now that you ve written the code to generate a single row, you need to add in more rows. Go back to your generate positions block. generate positions rows set y_pos to -150 set x_pos to -200 add x_pos to x_positions add y_pos to y_positions change x_pos by 400 / - 1 Now you need another loop that will the same number of times as the number of rows you need. Place it into your script as shown below. https://projects.raspberrypi.org/en/projects/lineup/print 9/14

generate positions rows set y_pos to -150 rows set x_pos to -200 add x_pos to x_positions add y_pos to y_positions change x_pos by 400 / - 1 Next you need to increase the value of y_pos. This will increase up to a maximum of 150, which is 300 away from its starting value of -150. This needs to happen for each row your create. generate positions rows set y_pos to -150 rows set x_pos to -200 add x_pos to x_positions add y_pos to y_positions change x_pos by 400 / - 1 change y_pos by 300 / rows - 1 Then you need to make sure you re passing the number of rows as a parameter to your blocks. when clicked clear generate positions 4 10 stamp sprite 4 10 If you run your code now, you won t get a neat grid of stamps. This is because your stamp sprite block is only ing for the total number of. It needs to for the product of the number of and the number of rows ( * rows). https://projects.raspberrypi.org/en/projects/lineup/print 10/14

stamp sprite rows set size to 40 % * rows set index to pick random 1 to length of x_positions go to x: item index of x_positions y: item index of y_positions delete index of y_positions delete index of x_positions stamp next costume Placing your sprite Now it s time to position your sprite amongst the stamps. You ll notice at the moment that your sprite will overlap one of the stamps. So this doesn t happen, you can just make your stamp loop run one time less: (rows * ) - 1 stamp sprites row set size to 40 % rows * - 1 set index to pick random 1 to length of x_positions go to x: item index of x_positions y: item index of y_positions delete index of x_positions delete index of y_positions stamp next costume If you run the script now, then your sprite still overlaps with a stamp, but there should be a hole in your grid of stamps. If you look have your x_positions and y_positions list, then you ll also see that there is one coordinate position left. To nish o this part the game, you ll need to continue the green ag section of the scripts. when clicked clear generate positions 4 10 stamp sprite 4 10 Here s what it needs to do: Send your sprite to x:0 y:0 Bring the sprite to the front and set its size to 100% https://projects.raspberrypi.org/en/projects/lineup/print 11/14

Say Find me for two seconds Move back one layer Set the sprite s size to 40% Move to the last remaining position in the lists Here s an animation showing what should happen See if you can do this independently, and use the hints below if you need more help. I need a hint To move your sprite to the correct location, you can use this code: when clicked clear generate positions 4 10 stamp sprites 4 10 go to x: 0 y: 0 go to front set size to 100 % say Find me for 2 secs go back 1 layers set size to 40 % go to x: item 1 of x_positions y: item 1 of y_positions Finishing the game To nish o, you ll need to nd and download an image of a curtain or a screen (https://www.google.co.uk/search? q=stage+curtain&source=lnms&tbm=isch&sa=x&ved=0ahukewjkg9o1k8_vahxsl1akhe1hdmiq_auicigb&biw=1362&bih=584). This image needs to be imported as a second sprite. Adding a sprite from a le Click Choose sprite from le to open up a le browser. Choose a le and click on Open when you are done. https://projects.raspberrypi.org/en/projects/lineup/print 12/14

To begin with, position the curtain sprite at x:0 y:0 and then change its size so that it lls the screen. You also want to make sure it is visible. when clicked go to x: 0 y: 0 set size to 110 % show Then, back on your character sprite, add a broadcast of curtain up to the end of the starting script. when clicked clear generate positions 4 10 stamp sprites 4 10 go to x: 0 y: 0 go to front set size to 100 % say Find me for 2 secs go back 1 layers set size to 40 % go to x: item 1 of x_positions y: item 1 of y_positions broadcast curtain up On the curtain sprite, you need a script that will do the following: Bring the curtain to the front Wait a little bit while the sprites all get drawn Glide the curtain upwards so it s near the top of the screen Hide the curtain Start a loop that counts for 10 seconds When the time is over, show the curtain Glide the curtain back to its original position Here s what it should look like: Have a go at doing this yourself, and use the hints if you need help. I need a hint https://projects.raspberrypi.org/en/projects/lineup/print 13/14

Here s the full script: when I receive Curtain up go to front wait 1 secs glide 1 secs to x: 0 y: 300 hide set timer to 10 10 wait 1 secs change timer by -1 show glide 1 secs to x: 0 y: 0 The very last part is to let the player know if they ve won. On the character sprite, if the sprite is clicked, it should say You've found me, all the scripts in the game should be stopped. Taking it further Here are some ideas for further additions to your game that could make it more interesting. Can you alter your scripts so that you can use even more costumes? How about choosing a background and then making the sprites nearer the top of the screen appear smaller, so they seem further away? Can you make the game, and provide you with a score based on your time to complete ve attempts? Published by Raspberry Pi Foundation (https://www.raspberrypi.org) under a Creative Commons license (https://creativecommons.org/licenses/by-sa/4.0/). View project & license on GitHub (https://github.com/raspberrypilearning/lineup) https://projects.raspberrypi.org/en/projects/lineup/print 14/14