12

CS in Algebra | Lesson 12

# The Big Game - Animation

Lesson time: 30-60 Minutes

## Lesson Overview

Returning to the Big Game we started in stage 7, students will use the Design Recipe to develop functions that animate the Target and Danger sprites in their games.

## Lesson Objectives

### Students will:

• Design functions to solve word problems.

• Use the Design Recipe to write contracts, test cases, and function definitions.

## Anchor Standard

### Common Core Math Standards

• F.LE.2: Construct linear and exponential functions, including arithmetic and geometric sequences, given a graph, a description of a relationship, or two input-output pairs (include reading these from a table).

Additional standards alignment can be found at the end of this lesson

# Teaching Guide

## Getting Started

### 1) Introduction

Let's get back into that Big Game that we started in stage 7.

The primary goal here is to get the target (starting in the upper left) to travel from left to right and the danger (starting in the lower right) to travel from right to left. This is accomplished in the update-target and update-danger blocks by changing the output of the function from its current default value of an unchanging x to some value relative to x.

Similar to the rocket-height puzzle, the update-target and update-danger functions are executed in order about every 10th of a second, to create the flip-book effect of movement. Each time these updates are executed, the functions take the CURRENT x coordinate as input and then return a new x coordinate such that the image's position changes. For each new execution of the update, the x coordinate set by the previous execution becomes the starting point.

One new thing the students should notice is that their modifications from stage 7 should still be in place. The Big Game will save a file for each student, and each level that they work on will benefit from the the changes made in previous levels. This means that it is very important that every student gets each Big Game level working correctly before moving on to the next stage.

It should also be noted that if a student returns to a previous level, or even a previous stage, that the MOST RECENT changes which they made will be the ones that they will see. Backing up to a previous level does NOT restore the previous state of the student's Big Game. Students are always looking at their most recent changes no matter which puzzle they are in.

# Lesson Tip

A contract can be quite long and often scrolls off the screen. To make dragging into the Definition area easier, consider collapsing the "1. Contract" and "2. Examples" areas by clicking on the arrow to the left of them.

## Activity: The Big Game - Animation

### 2) Online Puzzles

Using what you've learned about the Design Recipe you'll be writing functions that add animation to your game. Head to CS in Algebra stage 12 in Code Studio to get started programming. Note that when you click run, the title and subtitle will display for about 5 seconds before the other functions start.

Standards Alignment

### Common Core Math Standards

• 5.OA.1 - Use parentheses, brackets, or braces in numerical expressions, and evaluate expressions with these symbols.
• 5.OA.2 - Write simple expressions that record calculations with numbers, and interpret numerical expressions without evaluating them. For example, express the calculation “add 8 and 7, then multiply by 2” as 2 × (8 + 7). Recognize that 3 × (18932 + 921) is three times as large as 18932 + 921, without having to calculate the indicated sum or product.
• 6.NS.8 - Solve real-world and mathematical problems by graphing points in all four quadrants of the coordinate plane. Include use of coordinates and absolute value to find distances between points with the same first coordinate or the same second coordinate.
• 6.EE.9 - Use variables to represent two quantities in a real-world problem that change in relationship to one another; write an equation to express one quantity, thought of as the dependent variable, in terms of the other quantity, thought of as the independent variable. Analyze the relationship between the dependent and independent variables using graphs and tables, and relate these to the equation. For example, in a problem involving motion at constant speed, list and graph ordered pairs of distances and times, and write the equation d = 65t to represent the relationship between distance and time.
• 7.EE.4 - Use variables to represent quantities in a real-world or mathematical problem, and construct simple equations and inequalities to solve problems by reasoning about the quantities.
• 8.F.1 - Understand that a function is a rule that assigns to each input exactly one output. The graph of a function is the set of ordered pairs consisting of an input and the corresponding output.1
• 8.F.2 - Compare properties of two functions each represented in a different way (algebraically, graphically, numerically in tables, or by verbal descriptions). For example, given a linear function represented by a table of values and a linear function represented by an algebraic expression, determine which function has the greater rate of change.
• F.IF.1 - Understand that a function from one set (called the domain) to another set (called the range) assigns to each element of the domain exactly one element of the range. If f is a function and x is an element of its domain, then f(x) denotes the output of f corresponding to the input x. The graph of f is the graph of the equation y = f(x).
• F.IF.2 - Use function notation, evaluate functions for inputs in their domains, and interpret statements that use function notation in terms of a context.
• F.IF.4 - For a function that models a relationship between two quantities, interpret key features of graphs and tables in terms of the quantities, and sketch graphs showing key features given a verbal description of the relationship. Key features include: intercepts; intervals where the function is increasing, decreasing, positive, or negative; relative maximums and minimums; symmetries; end behavior; and periodicity.★
• F.IF.5 - Relate the domain of a function to its graph and, where applicable, to the quantitative relationship it describes. For example, if the function h(n) gives the number of person-hours it takes to assemble n engines in a factory, then the positive integers would be an appropriate domain for the function.★
• F.IF.6 - Calculate and interpret the average rate of change of a function (presented symbolically or as a table) over a specified interval. Estimate the rate of change from a graph.★
• F.BF.1 - Write a function that describes a relationship between two quantities.
• F.BF.2 - Write arithmetic and geometric sequences both recursively and with an explicit formula, use them to model situations, and translate between the two forms.★
• F.LE.1 - Distinguish between situations that can be modeled with linear functions and with exponential functions.
• F.LE.2 - Construct linear and exponential functions, including arithmetic and geometric sequences, given a graph, a description of a relationship, or two input-output pairs (include reading these from a table).

### Common Core Math Practices

• MP.1 - Make sense of problems and persevere in solving them.
• MP.2 - Reason abstractly and quantitatively.
• MP.3 - Construct viable arguments and critique the reasoning of others.
• MP.4 - Model with mathematics.
• MP.5 - Use appropriate tools strategically.
• MP.6 - Attend to precision.
• MP.7 - Look for and make use of structure.
• MP.8 - Look for and express regularity in repeated reasoning. 