Lesson 3: The Big Game - Animation

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.

Agenda

Getting Started

Activity

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).

Objectives

Students will be able to:

  • Design functions to solve word problems.
  • Use the Design Recipe to write contracts, test cases, and function definitions.

Links

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

For the Students

Support

Report a Bug

Teaching Guide

Getting Started

Teaching 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.

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.

Activity

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 course B, Stage 3 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.

View on Code Studio

Student Instructions

Now that you've learned to write simple linear functions, let's work on using them to add some movement to our game. Click "Run" to see what your game can currently do (not much!), update any variables you like, and then click finish to move on.

View on Code Studio

Student Instructions

The update-target function takes the target's current x value, and returns an updated value.

Complete update-target so that it adds to the x value each time it is called. The more you add to x, the faster the target will go.

View on Code Studio

Student Instructions

The update-danger function should work just like update-target, except that the danger should move from the right side over towards the left.

Complete update-danger to make the danger fly across the screen.

View on Code Studio

Student Instructions

At this point in your game your danger should run across the screen from right to left, and your target should run across from left to right.

They don't ever come back on screen once they've left, but we'll take care of that later.

Take a minute to make sure your game is working like you want it to, and then click "Finish" to move on.

Standards Alignment

View full course alignment

Common Core Math Standards

BF - Building Functions
  • 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.★
EE - Expressions And Equations
  • 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 va
  • 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.
F - Functions
  • 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
IF - Interpreting Functions
  • 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 c
  • 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: intercep
  • 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 w
  • 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.★
LE - Linear, Quadratic, And Exponential Models★
  • 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).
MP - 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
NS - The Number System
  • 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.
OA - Operations And Algebraic Thinking
  • 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 t
Q - Quantities
  • N.Q.1 - Use units as a way to understand problems and to guide the solution of multi-step problems; choose and interpret units consistently in formulas; choose and interpret the scale and the origin in graphs and data displays.
  • N.Q.2 - Define appropriate quantities for the purpose of descriptive modeling.