Top Banner
Scratch More complex scratch
14

Scratch

Feb 23, 2016

Download

Documents

Jovan

Scratch. More complex scratch. Lesson Objectives. Understand the concept of a variable Using the random function Move towards Keep track of score using a variable. Setting up the need for a variable. Before we learn about variables we must create the “need” for them! - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Scratch

Scratch

More complexscratch

Page 2: Scratch

Lesson Objectives

● Understand the concept of a variable● Using the random function● Move towards● Keep track of score using a variable

Page 3: Scratch

Setting up the need for a variable

● Before we learn about variables we must create the “need” for them!

● First of all we will create a baddie which will move towards the player

Page 4: Scratch

Move towards

● Baddie moves towards pucman until they touch

● That is game over!● Otherwise it points

towards him● And moves slowly!

Page 5: Scratch

Activity

● Add a baddie and make it move towards pucman.

● Use collect version 1 to help you

Page 6: Scratch

Items reappears!

● Forever will keep looping, err, forever!● It will repeat whatever is inside it● When collected it will move to a new postion

Page 7: Scratch

Random position

● Pick random (under operators) allows you to pick a number between a set of values.

● This allows you to pick a new X and Y position for your item!

Page 8: Scratch

Activity

● Get your item to move once collected!

Page 9: Scratch

Variables

● A variable is something which can change!● It must have a name (so we can refer to it)● And a value!

● The value can change over time and can be checked● In a loop or a if statement

● A score will be a variable

Page 10: Scratch

How a score will work

● Initially set to 0 on game start● When a item is picked up it will increase by

a set amount● On game over it will be displayed!.

Page 11: Scratch

Adding a score

● Click on make a variable● Call it score!● You should see the

options shown on the right

Page 12: Scratch

Setting score to zero

● This script should be added to the player.

Page 13: Scratch

Item code

● The item needs to change the score.● This is added to the item's code as shown

below.

Page 14: Scratch

Activity

● Add score to your game.

● If your feeling adventurous.● Open up collect version 2.● See how it works● Add it to your game!