Day 60 (WC)

Lesson 9: Sprite Movement

Game Lab

Overview

By combining the Draw Loop and the Counter Pattern, students write programs that move sprites across the screen, as well as animate other sprite properties.

Purpose

This lesson combines the Draw Loop that students first saw in Lesson 7 and the Counter Pattern that they learned in Lesson 8 to create programs with purposeful motion. By either incrementing or decrementing sprite properties, such as sprite.x, you can write programs that move sprites in expected patterns, instead of the randomization that we used in the past. The animations that students learn to create in this lesson lay the foundation for all of the animations and games that they will make throughout the rest of the unit.

Objectives

Students will be able to:

  • Use the counter pattern to increment or decrement sprite properties
  • Identify which sprite properties need to be changed, and in what way, to achieve a specific movement

Warm Up (5 minutes)

The purpose of this discussion is to start students thinking about how they might use the various sprite properties they’ve seen so far to make animations with purposeful motion. If students struggle to come up with ideas, you can narrow down the question to specific properties. For example:

  • What would happen to a sprite if you constantly increased its x property?
  • What would happen to a sprite if you constantly increased its y property?
  • What about other properties, or combining multiple properties?

Reviewing Sprite Properties

Prompt: On a piece of scratch paper, list out all of the sprite properties you can think of and what aspect of a sprite they affect.

Discuss: What kinds of animations could you make by combining sprite properties with the counter pattern? Consider both adding and subtracting from properties, or even updating multiple properties at the same time. Record ideas as students share them on the board.

Activity (40 minutes)

Levels: Sprites and Images

Transition: Send students to Code Studio.

Support: Students should be progressing through the levels without stopping in this class. When they have finished the skill building levels they are given the option of which project they wish to extend.

 Code Studio levels

  • Lesson Overview
  • Video: Sprite Movement

Discussion Goals

Students may describe the counter patten in various ways. Make sure that they go beyond just stating the blocks or code that the counter pattern uses. They should understand that the counter pattern allows the programmer to update the value of a variable in a pattern that counts up (or down) on every iteration of the draw loop. This can be used for many different things, such as spinning, growing, shrinking, or timers, but it’s most often used to move sprites across the screen.

When a sprite’s x or y property is updated in a counter pattern, its position changes in a consistent way over time, causing it to move across the screen. Students should be able to explain that movement in an animation is just a change in position, and that changing a sprite’s x position will cause it to move horizontally, and changing a sprite’s y position will cause it to move vertically.

  • Movement with the Counter Pattern
  • The Counter Pattern
  • Animating Sprites
  • Debugging with Watchers
  • Create Your Own Animation
  • Levels

Wrap Up (5 minutes)

Journal

Prompt: Have students reflect on their development of the five practices of CS Discoveries (Problem Solving, Persistence, Creativity, Collaboration, Communication). Choose one of the following prompts as you deem appropriate.

  • Choose one of the five practices in which you believe you demonstrated growth in this lesson. Write something you did that exemplified this practice.
  • Choose one practice you think you can continue to grow in. What’s one thing you’d like to do better?
  • Choose one practice you thought was especially important for the activity we completed today. What made it so important?

TRY THE LESSON 9 CHALLENGES

Leave a Reply

Your email address will not be published. Required fields are marked *