Download presentation
Presentation is loading. Please wait.
Published byEgbert Peters Modified over 9 years ago
1
Using Lists Games Programming in Scratch
2
Games Programming in Scratch Extension – Using Lists Learning Objectives Create a temporary data store (list) to hold multiple items Add items to the list Keep count of the number of items in the list Use the items in the list
3
Games Programming in Scratch Extension – Using Lists Starter How do you remember things you need to buy at a supermarket? How will you know when you have got all the items? How would you get a computer to check you have them all? Write some simple instructions for this
4
Games Programming in Scratch Extension – Using Lists Shopping Lists Repeat Think of item Add item to list Until you can’t think of any more items Repeat Look at first item in list Check item is in basket If item not in basket then Get item Else tick item Until end of list
5
Games Programming in Scratch Extension – Using Lists Variables or Lists Variables are great for individual pieces of information like scores, lives and health. However, sometimes we want to store a list of information. For example, in an RPG game you might want to keep a list of the items you have collected in your bag. For this, you need to use a LIST
6
Games Programming in Scratch Extension – Using Lists What is a List in Scratch? In Scratch, a List is a special variable type that can contain multiple other variables. In other programming languages this is usually known as an Array
7
Games Programming in Scratch Extension – Using Lists Using Lists Build an inventory/bag into your game Write out the instructions (on some paper or a whiteboard) for what happens:- – If your main character comes into contact with a collectable item – When you want to use an item in your inventory/bag Compare your instructions with those of your peers. Will they work as intended?
8
Games Programming in Scratch Extension – Using Lists Challenge! Try to implement your instructions Modify your game so that you can collect items and add them to your inventory/bag
9
Games Programming in Scratch Extension – Using Lists Recalling the items in a list Simple method: Loop method:
10
Games Programming in Scratch Extension – Using Lists Comment your Code Add comments to your code to help explain what each part does
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.