Next Customer Please

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

Projects

Next customer please


A shop simulation project where the customer can
buy items.

Step 1 Introduction

Make a shop app where the customer can buy items from your shop. The project will be in first-person view where
the player is a customer.

First-person view means that you don’t see your character on the screen, instead you see what they see.

You will:

Create a shop app with items to buy and a checkout


Plan your time to get a simple version working quickly
Try shops made by others and share your shop so others can try it

Get inspiration
You are going to make some design decisions to create your character. See inside example projects in Scratch 2:
Next customer please! - Examples (https://scratch.mit.edu/studios/29611454/) Scratch studio.
Step 2 Your business idea

What is your business idea? It could be something realistic,


something from a book or movie you like, or something
completely silly.

Open a new Scratch project (http://rpf.io/scratch-new) and look at the range of sprites and
backdrops that you can use. Spend some time thinking about your business idea.

Working offline
For information about how to set up Scratch for offline use, visit our ‘Getting started with Scratch’
guide (https://projects.raspberrypi.org/en/projects/getting-started-scratch/1).

What backdrop and extra scenery sprites will you need?

A backdrop from the Scratch library, or a plain coloured backdrop?


A desk, counter, or window to sell from?
A shelf or bookcase to put items on — you could Paint this on the backdrop

Click Choose a Backdrop or paint your own backdrop.

Click Choose a Sprite and add or paint extra scenery sprites.

You can always add more scenery later if you find that you need it.

What will the seller sprite look like?


A person or non-player character such as a shopkeeper, farmer, or librarian?
A machine such as a vending machine, jukebox, or cash register?

An NPC is a non-player character that you can interact with in a game or interactive story. Can you think of
games you have played that have NPCs? Next time you play, think about how it was someone’s job to make
that character.
Add a sprite to represent the seller.

What is the name of your business?


Create a variable called name:

Create a variable
From the Variables blocks menu click the Make a Variable button.

Call your new variable name:

Notice: The new name variable appears on the Stage and can now be used in the Variable blocks.

Click on your seller sprite and add code to set the variable to the name of your business:

when clicked

set name to type the name of your business

Create a sign on the Stage with your variable:

Change the appearance and position of variables


Right-click on the variable on the Stage and choose large readout:

Drag your variable to position it on the Stage as part of the shop scenery.
Test: Make sure you can see your business name as the value of the variable on the Stage.

Get ready to welcome your first customer.

Click on your seller sprite and add a broadcast block. Creat a new message called next customer.

when clicked

set name to my shop your business name

broadcast next customer

Create a new script for your seller sprite to say Next customer please when they receive the
broadcast next customer.

when I receive next customer

say Next customer please! for 2 seconds

Debug: You might find some bugs in your project that you need to fix. Here is a common bug.

Variable shows `0`

You should use the set [name v] to () block to set the variable to your name. If you have already
added a script, check that you have typed your business name into the value and clicked the green
flag.

when clicked

set name to my shop your business name


Save your project
Step 3 Items for sale

Your shop needs items for sale. Each item will have a price
that will be added to a total variable.

You will need to keep track of how much your customer is spending.
Add a new variable called total for all sprites.

Click on your seller sprite and add a script to set the total to 0 when the project starts.

Make a variable and set a start value

Click on Variables in the Code 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.

The variable will show on the Stage:

If you want to hide the variable on the Stage, uncheck the box next to the variable in the Variables
blocks menu.

Setting a start value


If your variable should have the same starting value every time your project is run, then add a script to
set it:
when clicked

set total to 0

What items will your customer(s) be buying?


Some kind of food or drink
Sports equipment, toys, or gadgets
Magic wands, potions, or spell books
Clothing or other fashion items
Your idea

Add a sprite for the first item you’re going to sell in your shop.

If you like, you can add a price to the costume using the text tool in the Paint editor. Or add a price to the
backdrop and position the item next to it.
Add a script to change the total by the price of your item when the customer clicks on the sprite.

Click to add an item

when this sprite clicked

start sound Coin

change total by 10

It’s also a good idea to play a sound to give the customer feedback that they have added an item.

Add a sound to a sprite or the Stage


Select the sprite that you want to have the new sound, then select the Sounds tab. Each sprite starts
with a default sound:

Scratch has a library of sounds that you can add to your sprites. Click on the Choose a Sound icon to
open the Sound Library:

To play a sound, hold your mouse cursor (or your finger, if you are using a tablet) over the Play icon:
Click on any sound to add it to your sprite. You will be taken straight back to the Sounds tab and you
will be able to see the sound that you have just added:

If you switch to the Code tab and look at the Sound blocks menu, you will be able to select the new
sound:

Tip: You can also add sounds to the Stage.

Test: Click on your item and check that the value of the total variable increases by the price of the
item, and you hear the sound effect. Click more times to see the total go up.

Click the green flag to start your project and make sure that the total starts at 0.
Add more items to your shop.
You can either:
Duplicate the first item and then add a new costume in the Paint editor
Add a sprite and then drag the when flag clicked script from the first item to your new item

Add a price label to the costume or backdrop if you are using them.

Click on your new Item sprite in the Sprite list then click on the Code tab.
Change the amount the total changes by to the price of your new item.

Test: Click the green flag to start your project and click on items to add them. Check that the total
increases by the correct amount each time you click on an item.
If you have added price labels, make sure they match the amount that gets added to the total, or your
customers will be confused!

Debug: You might find some bugs in your project that you need to fix. Here are some common bugs.

The total doesn't go to 0 when I click the green flag


Check that you have set the start value of the total variable in the when flag clicked script on
your seller sprite.

The total doesn't increase by the correct amount when I click on an item
Check that each item has a when this sprite clicked script that changes the total by the
correct amount for that item — you might have changed the price for the wrong sprite.
Check that you have used the change block and not the set block to change the total. You need to
use change to add the price to the total, you don’t want to set the total to the price of the item that
was just added.

Save your project


Step 4 Purchases

The seller sprite needs to:


ask if the customer is ready to pay for the items
take payment
get ready for the next customer
When they have finished choosing items, the customer will click on the seller sprite to pay.

Tell the customer how much their items will cost.

when this sprite clicked

say join That will be total for 2 seconds


Add a payment sound to your seller sprite so the customer knows that payment is taking place.

Add a sound to a sprite or the Stage


Select the sprite that you want to have the new sound, then select the Sounds tab. Each sprite starts
with a default sound:

Scratch has a library of sounds that you can add to your sprites. Click on the Choose a Sound icon to
open the Sound Library:

To play a sound, hold your mouse cursor (or your finger, if you are using a tablet) over the Play icon:

Click on any sound to add it to your sprite. You will be taken straight back to the Sounds tab and you
will be able to see the sound that you have just added:
If you switch to the Code tab and look at the Sound blocks menu, you will be able to select the new
sound:

Tip: You can also add sounds to the Stage.


Add the play sound until done block to your script.

when this sprite clicked

say join That will be total for 2 seconds

play sound machine until done


Finish the sale. Set total back to 0 after payment, say goodbye and broadcast next customer.

when this sprite clicked

say join That will be total for 2 seconds

play sound machine until done

set total to 0

say join Thanks for shopping at name for 2 seconds

broadcast next customer


You might want to give the customer the option to cancel their shopping.

Set up pay and cancel options


Ask Would you like to pay or cancel?. Add an If block for answer = pay and inside it put
your existing payment blocks.

when this sprite clicked

say join That will be total for 2 seconds

ask Would you like to pay or cancel? and wait

if answer = pay then

play sound machine until done

set total to 0

say join Thanks for shopping at name for 2 seconds

broadcast next customer

Add a second If block for answer = cancel and inside it add code to cancel the order.
when this sprite clicked

say join That will be total for 2 seconds

ask Would you like to pay or cancel? and wait

if answer = pay then

play sound machine until done

set total to 0

say join Thanks for shopping at name for 2 seconds

broadcast next customer

if answer = cancel then

set total to 0

say Ok. No problem for 2 seconds

broadcast next customer


To make sure your customer has items in their basket before paying, you can insert an if...else
block.

Check total amount

If total > 0 then insert your existing script.

Else say a helpful message.


when this sprite clicked

if total > 0 then

say join That will be total for 2 seconds

ask Would you like to pay or cancel? and wait

if answer = pay then

play sound machine until done

set total to 0

say join Thanks for shopping at name for 2 seconds

broadcast next customer

if answer = cancel then

set total to 0

say Ok. No problem for 2 seconds

broadcast next customer

else

say Click on the items you'd like for 2 seconds

Test: Test your project and make sure:


The customer can check out with the correct sound effects
The total gets set back to 0 after a customer pays or cancels.
Debug: You might find some bugs in your project that you need to fix.
Here are some common bugs:

The seller doesn't do anything when I click on them

You have quite a lot of sprites in your project. Make sure the when this sprite clicked script is
on your seller sprite.
Tip: If you have added it to the wrong sprite, you can drag the code to the seller sprite, then delete it
from the other sprite.

The seller says 'total' not the total amount

Make sure your say block has the total variable block, not the word total.

when this sprite clicked

say join That will be total for 2 seconds

The words in the say blocks merge together


When you join two pieces together, you need to add a space at the end of your first piece of text or
at the beginning of your second piece of text.
These have a space at the end of the first part of the join:

say join That will be total for 2 seconds

say join Thanks for shopping at name for 2 seconds

The total doesn't reset after a sale


Check that you have used:

set total to 0

not:
change total by 0

The seller isn't responding


Make sure the operator in the if condition is the greater than symbol >.

if total > 0 then

Tip: Compare your code with the code examples. Are there any differences that shouldn’t be there?

Save your project


Step 5 Additional features

There are lots of features you could add to improve your


customers’ shopping experience. You don’t need to add
everything. Just add improvements that you think are
important.
You can ‘See inside’ the example projects to look at how they work.
Example projects:
Fresh Space Fruit: See inside (https://scratch.mit.edu/projects/528696418/editor)
Cool Shirts: See inside (https://scratch.mit.edu/projects/528697069/editor)
Ice cream shop: See inside (https://scratch.mit.edu/projects/525972748/editor)
Vending machine: See inside (https://scratch.mit.edu/projects/526051796/editor)
Tip: If you are logged in to a Scratch account, then you can use the Backpack to copy scripts or sprites to your
project.

Using the Scratch Backpack


You can use your Scratch Backpack to store costumes, sprites, sounds, and scripts that you want to copy
between projects.
You can only access your own Backpack, and you must be logged in to your Scratch account to use it.
To open your Backpack, click on the Backpack tab at the bottom of the screen.

To add a sprite to your Backpack, drag the sprite from the Sprite list to the Backpack. This will store the full
sprite in your Backpack, including all of its costumes, sounds, and scripts.

To add a backdrop to your Backpack, select the Stage pane and click on the Backdrops tab, then choose
the backdrop that you want and drag it to your Backpack.
To use an item in your Backpack in another project, open the project and drag the item from the Backpack
to the correct pane or tab.

To delete an item in your Backpack, find the item in the Backpack tab, then right-click (or on a tablet, tap
and hold) on the item and select delete.

You can hide your Backpack when you are not using it. To do this, click on the Backpack tab at the bottom
of the screen.
Do you think your checkout person (or machine) should ask more questions?
You can add ask blocks to your seller’s when this sprite clicked script and say different things
depending on the customer’s response.

You could ask whether the service was good, or if they’re having a nice day. Or something specific to
your shop, like “What are you going to cook?”

Ask and respond to questions

ask Did you find everything you wanted today? and wait

if answer = yes then

say That's fantastic! for 2 seconds

else

say Maybe I should add more items to my shop for 2 seconds

Debug: Check that you have spelled the options correctly in your code and in your answer. It’s OK if
you use capital letters, so “Yes” and “YES” will match “yes”.
Add multiple questions to create a chatbot or non-player character that you can talk to.

Do you want something else to happen when you add an item?


The Cool Shirts project has shirts that glide into a bag.

Make items glide into a container


Add a Container sprite. You could use an existing sprite like the Gift or Take out sprite, or paint your
own with simple shapes.
Add a script to make the Container always appear at the front:

when clicked

forever

go to front layer

Then you’ll need to add code to each Item you have for sale to make them glide to the container
when they are clicked:

when this sprite clicked

go to front layer

glide 1 secs to Bag use the name of your Container sprite

hide

change total by 12

go to x: -180 y: 68 start position

show

If you don’t want the container there all the time, you can add scripts to make it show and hide at the
right time:
when I receive next customer

hide previous customer takes the bag

wait 1 seconds

show

Test: Try your project and make sure items glide to the container and hide.
Debug: Check your scripts carefully and make sure you have updated all of your Item sprites. You can
look at Cool Shirts (https://scratch.mit.edu/projects/528697069/editor) if you need to see a
working example.
The Ice cream project shows the ice cream as the customer chooses their options.

Customise and show a sprite


Each item needs to broadcast in its when this sprite clicked script:

broadcast 1 scoop

Then the sprite you want to show or change needs to respond to that message:

when I receive 1 scoop

play sound Chomp until done

switch costume to 1 scoop

You may also want to change or hide the sprite for a new customer:

when I receive next customer

switch costume to cone

If you have multiple items, then you will need to add more messages and scripts to to receive them.
Have you noticed that your customer can add items after they have started to check out?
If you want to stop the customer adding items when they are at the checkout, you can add a shop
variable and use it to control when items can be added.

Only allow purchases when the customer isn't at the checkout

Add a variable called shop for all sprites. You will set this to true when the customer is in the shop
and false when they are at the checkout.

Select your seller sprite. Update the when flag clicked script to allow shopping when your
project starts:

set shop to true

Now add a block to change the shop to false at the beginning of your seller’s when this sprite
clicked script:

set shop to false

And a block to set the shop variable back to true at the end of the same script:

set shop to true

Now you need to update the items you sell to check the shop variable:

when this sprite clicked

if shop = true then

start sound Coin

change total by 10

You will need to do this for every item you sell in your shop.
Test: Click the green flag then try shopping. Check that you can still add items and checkout, but you
can’t add items once you have started checking out.
Debug: Check your code really carefully. You can look at the Space Fruit (https://scratch.mit.edu/p
rojects/528696418/editor) project if you need to see a working example.
Save your project
Upgrade your project
If you have time you can upgrade your project.
Here are some ideas you could try:

Add more items to sell


Add more graphic and sound effects
Paint your own scenery and other costumes
Make another business and allow players to visit them both
Each example project in the Introduction (.) has a ‘See Inside’ link for you to open the project in Scratch, and look
at the code to get ideas and see how they work.
Take a look at our ‘Intergalactic shopping market’ (https://scratch.mit.edu/studios/29662180) Scratch studio
to see projects created by community members.

Save your project


Share
If you are in a club, why not share your project with friends?
If you are logged in on Scratch, you can create a studio and add your Next customer please project. You can also
add your friends’ Next customer please projects to create a mall of different shops and businesses.

Build a shopping market


Save your project, then click on your username and select My Stuff.

From your My Stuff page, click on the + New Studio button.

Give your new studio a name and description.

Click on the Add projects button. You can add yor own project by selecting it from the list at the bottom of the
page.

You can also add projects your friends have created. Ask them to share their project and give you the link. Type
or paste the link into the url box, then click the Add by url button.
The url box underneath the 'Add projects'
button and the 'Add by url' button.

Share your project and send a link to people you know. The whole Scratch community will also be able to find your
project and try it out.
Share your Scratch project
Please make sure that you do not share any personal information about yourself when sharing your Scratch
projects.

Give your Scratch project a name.

Click the Share button to make the project public.

If you like, you can add instructions in the Instructions box, to tell other people how to use your project.

You can also fill in the Notes and Credits box: if you have made an original project, you can write some
short comments, or if you have remixed a project, you can credit the original creator.

Click the Copy Link button to get the link to your project. You can send this link to other people by email or
text, or on social media.

Scratch provides the ability to comment on your own and other people’s projects. If you do not want to allow
people to comment on your project, you should turn off commenting. To turn off commenting, set the slider
above the Comments box to Commenting off.

Why not invite your friends to create a project? Let them know how you had fun.
If you have a Scratch account, and have shared your Next customer please project, keep an eye out for
comments that others may make about your creation. Feedback is a great way to reflect on your work. Ignore any
comments that are unhelpful or irrelevant.

Comments and feedback in Scratch


Scratch provides the ability to comment on your own and other people’s projects. If you do not want to allow
people to comment on your project, you should turn off commenting. To turn off commenting, go to the Project
Page and set the slider above the Comments box to Commenting off:

If you are happy and feel safe to allow people to write comments on your project, you can leave the first
comment:

If you think a comment or project is mean, insulting, too violent, or otherwise inappropriate, click the Report
button to let the Scratch Team know about it. To report a comment, click the Report button above the
comment. To report a project, click the Report button on the Project Page:

Read the Scratch Community Guidelines (https://scratch.mit.edu/community_guidelines) so that you


know how you and others can maintain a friendly and creative community.

Inspire the Raspberry Pi Foundation community with your project!


To submit your project to our ‘Intergalactic shopping market’ (https://scratch.mit.edu/studios/296
62180) Scratch studio, please complete this form (https://form.raspberrypi.org/f/community-proje
ct-submissions).
What next?
If you are following the More Scratch (https://projects.raspberrypi.org/en/raspberrypi/more-scratch) path,
you can move on to the Don’t fall in (https://projects.raspberrypi.org/en/projects/dont-fall-in) project. In this
project, you will make a top-down game where you have to jump from platform to platform and not fall in.
Don't fall in project

If you want to have more fun exploring Scratch, then you could try out any of these projects (https://projects.ra
spberrypi.org/en/projects?software%5B%5D=scratch&curriculum%5B%5D=%201).

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/next-customer-please)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy