< Course F (2021)

Lesson 3: Sprites in Action

55 minutes

Overview

In this skill-building lesson, students will work through a series of programming levels on the computer, finishing with an open-ended “free play” task where they can build whatever they like. Students will write programs that respond to timed events and user input.

Purpose

This lesson is designed to reinforce skills from the previous lesson and introduce students to programming with events. Throughout this course, events will be the primary way students change how their programs run over time or in response to the user.

CSTA K-12 Computer Science Standards (2017)
    • 1B-AP-08 - Compare and refine multiple algorithms for the same task and determine which is the most appropriate.
    • 1B-AP-10 - Create programs that include sequences, events, loops, and conditionals.
    • 1B-AP-12 - Modify, remix or incorporate portions of an existing program into one's own work, to develop something new or add more advanced features.

Agenda

Objectives

Students will be able to:
  • Create an interactive animation using events.
  • Develop programs that respond to timed events.
  • Develop programs that respond to user input.

Preparation

Play through the levels and review the lesson slides.

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the teachers

Vocabulary

  • Algorithm - A list of steps to complete a task.
  • Event - An action that causes something to happen.

Teaching Guide

Warm Up (15 minutes)

Do this: Review or introduce the word algorithm: a list of steps to complete a task.

Follow the Algorithm

Remarks

Today we’re going to start with a quick game. In this game, I will be giving you all commands to follow and your job is to follow the algorithm. The commands will always start with “begin” or “stop”. If I tell you to begin doing something, you need to start that behavior and keep it going until I tell you to stop. I might also tell you to “stop everything” which means you can end all of the behaviors I’ve given you so far. We’ll play 3 rounds and after each round I’ll ask you all a couple questions.

Teaching Tip

Be sure to give a little space between commands. For each of these sections, consider running through the entire sequence without any discussion and later repeating it again after everyone has had a chance to debrief and process any confusion.

Round 1 (Basic):

  • Begin marching in place.
  • Stop marching in place.
  • Begin clapping.
  • Stop clapping.
  • Begin marching in place.
  • Begin clapping.
  • Stop everything.

Discussion: What happened when you were told to clap but you were already marching in place? What happens if you are told to begin two different behaviors at once?

Students should understand that multiple behaviors can happen simultaneously.

Round 2 (Intermediate):

  • Begin waving your arms in the air.
  • Begin bobbing your head.
  • Stop waving your arms in the air.
  • Stop bobbing your head.
  • Begin shaking your knees.
  • Begin flapping your arms like a bird.
  • Stop shaking your knees.
  • Begin bobbing your head.
  • Begin marching in place.
  • Stop flapping your arms like a bird.
  • Stop everything.

Discussion:

What kinds of instructions caused people to make mistakes? What strategies do you think are helpful for making sure you follow instructions correctly? Why is it important to keep track of each behavior separately?

Students should understand that each behavior needs to be stopped individually. They need to keep track of each one separately.

Challenging

  • Begin crouching.
  • Begin tapping your head.
  • Stop crouching.
  • Stop tapping your head.
  • Begin jumping up and down.
  • Begin tapping your head.
  • Stop everything.
  • Begin clapping.
  • Begin flapping your arms like a bird.
  • Stop everything.
  • Begin crouching.
  • Begin jumping up and down.
  • Stop everything.
  • Begin tapping your knees.
  • Begin tapping your head.
  • Stop everything.
  • Begin spinning to the left.
  • Begin spinning to the right.
  • Stop spinning to the left.
  • Stop spinning to the right.

Discussion: What happens if two behaviors seem to conflict with each other?

What should you do when told to clap your hands and flap your arms at the same time?

How can you jump up and down while crouching?

What happens if you need to tap your knees and your head at the same time?

When you were told to spin in two opposite directions what did you see people do?

What would happen if you were told to spin left and right at the exact same time?

Students should understand that some behaviors conflict with each other which can result in unexpected outcomes. It’s possible for two opposite behaviors to effectively cancel each other out.

Main Activity (35 minutes)

Sprites in Action

Prediction (2 mins)

Do This: Have students read the provided code and make a prediction about what will happen. After pressing “Run”, provide time for students to reflect on anything they found interesting or that surprised them.

Video: Sprites in Action (3 mins)

Do This: Play the video, “Sprites in Action”

Skill Building and Practice (20 mins)

Transition: Have students move to their computer and sign in. These activities are suitable for independent learning or pair programming.

Students should complete the Skill Building levels and then spend any remaining time choosing from the various Practice activities.

Free Play (10 mins)

Transition: Students should now skip to the final level in the lesson where they will see the same free play choices as the previous lessons. Encourage students to add events to their projects from last time, or begin a new project.

Teaching Tip

The free play choices in this lesson mirror those from the previous lesson. In fact, any student code from the last lesson will carry over to today. The main difference is that now students have additional blocks in their toolbox which they should use to make their programs more interesting or complex.

Wrap Up (5 minutes)

Reflection

Remarks

Today you learned to create programs that change over time using events.

Event - An action that causes something to happen.

Journaling

Having students write about what they learned, why it’s useful, and how they feel about it can help solidify any knowledge they obtained today and build a review sheet for them to look to in the future.

Prompts: Arrow keys are one way to make a program more interactive. What other ways could we give a user control over what happens in an app or game?

Creative Commons License (CC BY-NC-SA 4.0).

This work is available under a Creative Commons License (CC BY-NC-SA 4.0).

If you are interested in licensing Code.org materials for commercial purposes contact us.