1 of 17

Lesson 1.1

Activity

Now, it’s time to look at how events help us tell computers what we want them to do!

Unit 0: Getting Started with Computer Science

2 of 17

Today’s Mission!

Tell your computer how to make a sprite perform a response after an event of your choosing occurs.

3 of 17

Scratch Project: Open a New Project

  1. Go to scratch.mit.edu.
  2. Log into your Scratch account.
  3. Click “Create”.
  4. Name your project “Events Practice”, then click “Share” to make it viewable by others.
  5. Add your project to the studio.

4 of 17

Scratch Project: Set the Stage

  1. First, choose a Sprite from the list by clicking the Cat button.
  2. Then, choose a background by clicking the background button.

1. Pick a sprite

2. Pick a background

5 of 17

Scratch Project: Add an Event

3. Click the shortcut button (at the left).

4. Next, drag the event block to your coding workspace. This creates a new event in your program.

3. Pick an event block (“when green flag clicked’)

4. Drag the event block to your workspace

6 of 17

Scratch Project: Add a Response

5. Click the shortcut button (at the left).

6. Next, drag the motion block to your coding workspace and change “10” to “30” degrees

7 of 17

Scratch Project: Add a Response

Congratulations...

You just created your first program!!

You gave the computer instructions on how to use an event block to move your sprite using Scratch

8 of 17

Scratch Project: Sequencing Blocks

Remember our discussion of sequencing?

You can use events to have many things happen in a sequence, by using blocks stacked one after another. The program will run each block in order from top to bottom.

Let’s create a sequence of blocks in your Scratch.

9 of 17

Scratch Project: Sequencing Blocks

You already have these blocks in place

Next:

1. Click and drag the ‘wait ___ seconds” block

2. Click and drag the “turn____ degrees” block

Keep adding blocks (alternating the direction of the turn)

10 of 17

Scratch Project: Sequencing Blocks

What happened to your sprite when you clicked the green flag?

How many things did the event trigger? In what sequence did these things happen?

11 of 17

Scratch Project: Parallel Blocks

Remember our discussion of parallelism?

You can use events to trigger sets of things that happen in parallel, at the same time.

Let’s create a parallel sequence of blocks using Scratch.

12 of 17

Scratch Project: Parallel Blocks

Add a parallel flow to your Scratch project.

Make sure the same event block is used at the start of each chain of blocks!

In parallel flow, two or more events can be triggered at the same time.

13 of 17

Scratch Project: Parallel Blocks

What happened to your sprite when you clicked the green flag?

How many things did the event trigger? In what sequence did these things happen?

14 of 17

Lesson 0.2

Close Out

Unit 0: Getting Started with Computer Science

15 of 17

Scratch Project: Mission Checklist

All done with your project? Check each of these steps:

  • My Scratch project has at least three events:
    • One event triggers a single response
    • One event triggers a sequence of responses
    • One event triggers parallel responses
  • My Scratch project is titled and is shared with my class.

Once you’ve finished, you can silently begin working on your workbook.

16 of 17

Let’s Review! Lesson Vocabulary

  • event (n): an action that causes something to happen
  • sequence (n): a series of instructions that follow one another in order
  • parallelism (n): sets of instructions that run at the same time
  • initializing (v): assigning an initial (beginning) value to a variable or object

17 of 17

Discussion: Events and Responses

  • What is an event?
  • What happens when you reset - or initialize - after an event?
  • Can the same event trigger lots of different actions?